【发布时间】:2021-07-20 05:46:48
【问题描述】:
正在开发一个新的网站抓取工具,但在获取 Div 之间的文本时遇到问题。我已经尝试过 .text 和 .strip() 但仍然无法获取文本。有什么建议吗?
URL = 'https://preview.mcassessor.maricopa.gov/mcs/?q=504-39-014'
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'}
page = requests.get(URL, header)
soup = BeautifulSoup(page.content, 'html.parser')
value = soup.find("div", {"id": "Valuations_0_LimitedPropertyValue"})
print (value.text.strip())
【问题讨论】:
标签: python web-scraping beautifulsoup