【发布时间】:2018-06-20 03:13:31
【问题描述】:
我正在开发我的第一个网站抓取工具,并试图获取保存在网页 https://mcassessor.maricopa.gov/mcs.php?q=14014003N 列中的数字 41,110。下面是我的代码。
我怎样才能得到这个号码并打印出来?
from bs4 import BeautifulSoup
import requests
web_page = 'https://mcassessor.maricopa.gov/mcs.php?q=14014003N'
web_header = {'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36'}
response = requests.get(web_page,headers=web_header)
soup = BeautifulSoup(response.content,'html.parser')
for row in soup.findAll('table')[0].thread.tr.findAll('tr'):
first_column = row.findAll('th')[0].contents
print(first_column)
【问题讨论】:
标签: html python-3.x web-scraping beautifulsoup findall