我真的是 Python 的新手,从昨天开始我就尝试使用 Beautifulsoup抓取craigslist 帖子的位置(城市或 googlemap 信息)。
我尝试了一种在网站上找到的方法: Using Beautiful Soup to get data from non-class section
但是当我使用时:
for url in (url_list):
page2 = requests.get(url)
soup = BeautifulSoup(page2.content, 'html.parser')
for address in soup.findAll("div", {"class": "mapaddress"}):
addressText = ''.join(address.findAll(text=True))
location.append(addressText)
我NameError: name 'addressText' is not defined
在最后一行,我不明白为什么。
如果有人可以提供帮助或提供其他解决方案,我将不胜感激,
非常感谢,