这是我想抓取的网页链接:https://www.tripadvisor.in/Restaurants-g494941-Indore_Indore_District_Madhya_Pradesh.html
我还通过单击环绕的标题1应用了其他过滤器
这是点击标题2后网页的外观
我想获取网页上显示的所有位置的名称,但我似乎遇到了问题,因为url在应用过滤器时没有更改。 我正在为此使用python urllib。 这是我的密码:
url = "https://www.tripadvisor.in/Hotels-g494941-Indore_Indore_District_Madhya_Pradesh-Hotels.html"
page = urlopen(url)
html_bytes = page.read()
html = html_bytes.decode("utf-8")
print(html)
您可以使用bs4。Bs4是一个python模块,允许您从网页中获取某些内容。这将从站点获取文本:
如果您想获取非文本的内容,也可以使用bs4:
找到所有地名的类和标记,然后使用上面的方法获得所有地名
https://www.crummy.com/software/BeautifulSoup/bs4/doc/
相关问题 更多 >
编程相关推荐