Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting error
#1
After following the post named https://python-forum.io/Thread-Not-able-...-a-webpage
I used this code to pick up the data as you suggested, In the 'url' variable I am taking my facebook profile -
from bs4 import BeautifulSoup
import requests

url = 'https://www.facebook.com/srayashri.saha.5'
url_get = requests.get(url)
soup = BeautifulSoup(url_get.content,'lxml')
print(soup.find(class_="_c24 _50f4").text)
but I am getting the following error though there are several classes where text is present -
Error:
[b]Traceback (most recent call last): File "/home/csurv_4/PycharmProjects/web_parsing/data_fetching.py", line 18, in <module> print(soup.find(class_= "_c24 _50f4").text) AttributeError: 'NoneType' object has no attribute 'text'[/b]
I want to know the mistake I am doing, and what to do if there are multiple classes with the same name. How I can retrieve the all the data with that class name?
Reply


Messages In This Thread
Getting error - by sumandas89 - Dec-21-2017, 11:13 AM
RE: Getting error - by wavic - Dec-21-2017, 12:28 PM

Forum Jump:

User Panel Messages

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