这是我的python3脚本:
import bs4, requests
def getCompAddress(https://www.google.com/search):
res = requests.get(https://www.google.com/search)
res.raise_for_status()
soup = bs4.BeautifulSoup(res.text, 'html.parser')
elems = soup.select('#rhs_block.LrzXr')
print(elems)
...的网址getCompAddress只是Google的搜索结果。因此,对于“五叉处的十字路口”,google在右侧显示地址和电话信息。我只想抓取我已复制到其CSS路径中的地址soup.select。
但是,当我运行此脚本时,所有显示的内容都是“ []” ...而不是地址。我在这里想念什么?Google可以防止这种刮擦吗?谢谢你的帮助!
幕布斯6054654
相关分类