我需要收集两个不同的数组,国家代码顶级域名(例如.ac)和国家(请参阅链接:https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains)。
我尝试获取我需要的信息,如下所示:
import requests
from bs4 import BeautifulSoup as bs
with requests.Session() as s: # use session object for efficiency of tcp re-use
s.headers = {'User-Agent': 'Mozilla/5.0'}
r = s.get('https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains')
soup = bs(r.content, 'lxml')
# print(soup.prettify)
tld_table=soup.find('table',{'class':'wikitable sortable'})
links=tld_table.findAll('a')但是当我考虑class: wikitable sortable时,它给了我错误的结果。
你能帮我弄清楚吗?
谢谢
发布于 2020-03-31 04:20:27
import pandas as pd
tables = pd.read_html("https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains")
tables[6] // is the table of the countrieshttps://stackoverflow.com/questions/60938764
复制相似问题