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'
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
please show full unaltered and compete error traceback (in bbcode error tags). It contains information needed to debug.Larz60+

Possibly Related Threads…
Thread Author Replies Views Last Post
  BeautifulSoup attribute problem zzy 3 554 Dec-07-2020, 11:07 PM
Last Post: zzy
  Beautifulsoup doesn't scrape page (python 2.7) Hikki 0 370 Aug-01-2020, 05:54 PM
Last Post: Hikki
  select all the span text with same attribute JennyYang 2 526 Jul-28-2020, 02:56 PM
Last Post: snippsat
  'NavigableString' object has no attribute 'h2' RandomCoder 5 1,094 May-20-2020, 09:01 AM
Last Post: Larz60+
  Python beautifulsoup pagination error The61 5 1,005 Apr-09-2020, 09:17 PM
Last Post: Larz60+
  Using Python to get attribute text furiousfrodo 2 968 Dec-18-2019, 04:18 PM
Last Post: furiousfrodo
  AttributeError: 'str' object has no attribute 'xpath' nazmulfinance 4 3,605 Nov-11-2019, 05:15 PM
Last Post: nazmulfinance
  AttributeError: 'str' object has no attribute 'xpath' nazmulfinance 0 941 Nov-10-2019, 09:13 PM
Last Post: nazmulfinance
  get function returns None from Beautifulsoup object DeanAseraf1 3 4,634 Aug-03-2019, 04:00 PM
Last Post: DeanAseraf1
  form.populate_obj problem "object has no attribute translate" pascale 0 1,397 Jun-12-2019, 07:30 PM
Last Post: pascale

Forum Jump:

User Panel Messages

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