Python 从维基百科页面获取URL列表

Python 从维基百科页面获取URL列表,python,web-scraping,scrapy,Python,Web Scraping,Scrapy,我有一份财富500强公司的名单。 以下是一个示例[Abbott Laboratories,Progressive,Arrow Electronics,Kraft Heinz Plains GP Holdings、Gilead Sciences、Mondelez International、诺斯罗普·格鲁曼] 现在我想从维基百科上获取列表中每个元素的完整url for example, after searching the name on Google or Wikipedia, it sho

我有一份财富500强公司的名单。 以下是一个示例
[Abbott Laboratories,Progressive,Arrow Electronics,Kraft Heinz
Plains GP Holdings、Gilead Sciences、Mondelez International、诺斯罗普·格鲁曼]

现在我想从维基百科上获取列表中每个元素的完整url

for example, after searching the name on Google or Wikipedia, 
it should give me back list of all wikipedia urls like: 

(这只是一个例子)

最大的问题是寻找可能的网站,只选择属于该公司的网站

一种有点错误的方法是将公司名称添加到wiki url,并希望它能正常工作。结果是a)它工作(像雅培实验室),b)它产生一个页面,但不是正确的页面(渐进的,应该是渐进的),或者c)它根本不产生任何结果

companies = [
    "Abbott Laboratories", "Progressive", "Arrow Electronics", "Kraft Heinz Plains GP Holdings", "Gilead Sciences",
    "Mondelez International", "Northrop Grumman"
]

url = "https://en.wikipedia.org/wiki/%s"

for company in companies:
    print(url % company.replace(" ", "_"))
另一个更好的选择是使用wikipedia包()及其内置的搜索功能。选择正确站点的问题仍然存在,因此您基本上必须手工操作(或者创建一个良好的自动选择,如搜索“公司”一词)


到目前为止,你所拥有的是。。。。张贴代码。如果您没有任何代码,请尝试编写一些代码,然后发布这些代码。
companies = [
    "Abbott Laboratories", "Progressive", "Arrow Electronics", "Kraft Heinz Plains GP Holdings", "Gilead Sciences",
    "Mondelez International", "Northrop Grumman"
]

import wikipedia
for company in companies:
    options = wikipedia.search(company)
    print(company, options)