Python 3.9 : BeautifulSoup: 'NoneType' object has no attribute 'text' - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: Python 3.9 : BeautifulSoup: 'NoneType' object has no attribute 'text' (/thread-32747.html) |
Python 3.9 : BeautifulSoup: 'NoneType' object has no attribute 'text' - fudgemasterultra - Mar-03-2021 So I am trying to pull data from a website via a scraper. When I try this code out I am getting an error wo_span_name = w_span_name.text AttributeError: 'NoneType' object has no attribute 'text'The weird part is the div, and class exsist, and if I don't try a .text command it will print the Div class "<div class=""phones phone primary"">(Data I am looking for)</div>"I know I am missing something small, but don't know what. ##Already have code to pull, and parcer the site into html for findcard in soupurl.find_all('div', class_="v-card"): #Declaring global varibles global wo_span_name global wo_div_phone #grab name w_span_name = findcard.find('a', class_='business-name') wo_span_name = w_span_name.text #grab phone number w_div_phone = findcard.find('div', class_="phones phone primary") wo_div_phone = w_div_phone.text #Adding items to list phone_list.append(wo_div_phone) name_list.append(wo_span_name) RE: Python 3.9 : BeautifulSoup: 'NoneType' object has no attribute 'text' - Larz60+ - Mar-03-2021 please show full unaltered and compete error traceback (in bbcode error tags). It contains information needed to debug.Larz60+ |