【发布时间】:2018-07-09 04:02:13
【问题描述】:
这是我的 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 的搜索结果。所以对于Crossings at Five Forks,google 会在右侧显示地址和电话信息。我只想抓取地址,我已将其 CSS 路径复制到 soup.select。
但是当我运行这个脚本时,打印出来的只是“[]”……而不是地址。我在这里想念什么?谷歌会阻止这种抓取吗?感谢您的帮助!
【问题讨论】:
标签: python css python-3.x web-scraping beautifulsoup