我正在尝试使用python请求html模块从“https://fortune/global500/2019/search/”获取数据。我能够获得前100项(从第一页),因为该页启用了javascript。我们需要点击“下一步”加载第二页,目前我只得到前100项。你知道吗

当我在浏览器上单击“下一步”时,地址栏上的url不会改变。所以我不知道如何使用html请求获取下一页。你知道吗from requests_html import HTMLSession

def get_fortune500():

companies = []

url = 'https://fortune/global500/2019/search/'

session = HTMLSession()

r = session.get(url)

r.html.render(wait=1, retries=2)

table = r.html.find('div.rt-tbody', first=True)

rows = table.find('div.rt-tr-group')

for row in rows:

row_data = []

cells = row.find('div.rt-td')

for cell in cells:

celldata = cell.text.lstrip('$').replace(',', '')

row_data.append(celldata)

companies.append(row_data)

return companies

fortune_list = get_fortune500()

print(fortune_list)

print(len(fortune_list))

我真的很感谢你抽出时间。你知道吗

更多推荐

html点击下一步,PythonWebScraping,如何使用RequestsHTML库单击“下一步”