Python Forum
Python 3.9 : BeautifulSoup: 'NoneType' object has no attribute 'text'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python 3.9 : BeautifulSoup: 'NoneType' object has no attribute 'text'
#1
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)
Reply
#2
please show full unaltered and compete error traceback (in bbcode error tags). It contains information needed to debug.Larz60+
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to fix "'dict_values' object has no attribute 'inject_wsgi'" in session_transacti devid 0 1,164 Aug-13-2023, 07:52 AM
Last Post: devid
  Strange ModuleNotFound Error on BeautifulSoup for Python 3.11 Gaberson19 1 976 Jul-13-2023, 10:38 AM
Last Post: Gaurav_Kumar
  Trying to extract style attribute with BeautifulSoup knight2000 1 3,062 Dec-28-2022, 03:06 AM
Last Post: knight2000
  AttributeError: 'ellipsis' object has no attribute 'register_blueprint' Mechanicalpixelz 2 2,387 Dec-29-2021, 01:30 AM
Last Post: Mechanicalpixelz
  Python BeautifulSoup gives unusable text? dggo666 0 1,426 Oct-29-2021, 05:12 AM
Last Post: dggo666
  BeautifulSoup returning text as N/A tantony 6 2,723 Sep-09-2021, 12:59 PM
Last Post: tantony
  Python BeautifulSoup IndexError: list index out of range rhat398 1 6,213 May-28-2021, 09:09 PM
Last Post: Daring_T
  AttributeError: 'NoneType' object in a parser - stops it apollo 4 4,013 May-28-2021, 02:13 PM
Last Post: Daring_T
  AttributeError: ResultSet object has no attribute 'get_text' KatMac 1 4,380 May-07-2021, 05:32 PM
Last Post: snippsat
  BeautifulSoup attribute problem zzy 3 3,014 Dec-07-2020, 11:07 PM
Last Post: zzy

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020