I'm really new on Python and I tried since yesterday to scrape location (city or googlemap information) of craigslist posts using Beautifulsoup.
I tried a way that I find on the site : Using Beautiful Soup to get data from non-class section
but when I use :
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)
I have NameError: name 'addressText' is not defined in the last line and I can't understand why.
If someone can help or offer an other solution I'd really appreciate,
Many thanks,
I think the problem is you didn't indent the code correctly. Try modifying it to