在URL https://www.airbnb.com/rooms/3093543处,有一张地图加载到页面底部附近,其中包含一个称呼Presidio的“邻居”框。它存储在标签中<a href="/locations/neighborhoods/479">Presidio</a>
我正在尝试与此:
profile = BeautifulSoup(requests.get("https://www.airbnb.com/rooms/3093543").content, "html.parser")
print profile.select('div[id="hover-card"]')[0].find('a').text
# div[id="hover-card"] is not found
我不确定这是否是只能通过另一个模块检索的动态变量,或者是否可以通过请求获取。
您可以通过另一个元素获取该数据。试试这个:
profile = BeautifulSoup(requests.get("https://www.airbnb.com/rooms/3093543").content, "html.parser")
print profile.select('meta[id="_bootstrap-neighborhood_card"]')[0]
如果需要,可以通过以下方式索取地图:
https://www.airbnb.pt/locations/api/neighborhood_tiles.json?ids%5B%5D=ID
上述URL中的ID由neighborhood_basic_info
第一张图片中的属性给出。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句