请求html页面与浏览器不同

时间:2018-08-22 14:14:16

标签: python python-requests

因此,当我转到带有python请求的页面时,它将呈现另一个页面。显然,这是一些脚本执行的。有什么办法可以在python中获取呈现同一页面的请求,以便我可以对其进行抓取?我真的才刚开始重新学习BeautifulSoup。

Page I want to scrape

sortedGroupedDictionary.map { $0.key }

1 个答案:

答案 0 :(得分:2)

看起来像是小型的o型sale-info应该是sales-info(请注意第二个 s ),请尝试以下操作:

import requests
from bs4 import BeautifulSoup

page = requests.get('https://www.yellowpages.com/new-orleans-la/mip/upperline-restaurant-526381149?lid=1001797484770')
soup = BeautifulSoup(page.text, 'html.parser')
# I am trying to find this class 'sales-info' but it isn't in the html when rendered.
business_name = soup.find('div', class_='sales-info')
print(business_name)

结果:

<div class="sales-info"><h1>Upperline Restaurant</h1></div>
相关问题