【发布时间】:2018-01-06 16:45:34
【问题描述】:
我正在尝试构建我的第一个网站抓取工具,并且对 Python 和一般编程非常陌生。我正在尝试练习抓取网站,但由于某种原因我的代码不起作用。请参阅下面的代码。当我运行代码时,它返回 google.com 的 html 而不是 County Assessors 页面。
这是我的 Python 代码的问题,还是 County Assessors 页面上的某些代码将我重新路由到谷歌?我该如何解决这个问题?任何帮助深表感谢。谢谢。
#IMPORT LIBRARIES
from urllib.request import urlopen
from bs4 import BeautifulSoup
import requests
#SCRAPER CODE
web_page = 'https://mcassessor.maricopa.gov/index.php'
page = urlopen(web_page)
soup = BeautifulSoup(page,'html.parser')
print (soup)
【问题讨论】:
标签: python html web-scraping python-requests urllib3