【发布时间】:2014-11-16 11:59:18
【问题描述】:
我正在使用Python 和BeautifulSoup 进行网络抓取。
我必须刮掉这个页面。
http://www.starwoodhotels.com//sheraton/property/reviews/index.html?language=en_US&propertyID=115
从这个页面,我已经成功抓取了酒店的地址,但是我无法抓取用户评论部分
这是我的代码
hotel_link = "http://www.starwoodhotels.com//sheraton/property/reviews/index.html?language=en_US&propertyID=115"
hotel_page_html = requests.get(hotel_link,headers = header).text
hotel_page_soup = BeautifulSoup(hotel_page_html)
for hotel_address in hotel_page_soup.select("div#propertyAddressContainer ul#propertyAddress"):
print("Address: "+hotel_address.select("li")[0].text)
print(hotel_page_soup.select("div.BVRRRatingNormalOutOf"))
如您所见,使用 CSS 选择器 div#propertyAddressContainer ul#propertyAddress,我得到了地址,但无法抓取 User Reviews 部分。
我在页面加载时检查了Console,但我没有看到任何用户评论是通过 AJAX 调用加载的。
那么我如何抓取评论部分?
【问题讨论】:
-
我需要看看哪个是获取评论的 URl?我在页面 HTML 中搜索过,但找不到它。谁能告诉我网址?
-
我通过 HTTP Fox 看到了所有网址,但似乎找不到它
-
如果某些条件不匹配,网站会重定向到移动网站。你在“header”变量中放了什么?
标签: python python-3.x beautifulsoup