Python Forum

Full Version: Getting error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
from bs4 import BeautifulSoup
import requests
 
url = 'https://www.facebook.com/srayashri.saha.5'
url_get = requests.get(url)
print(url_get.content)
# soup = BeautifulSoup(url_get.content,'lxml')
# print(soup.find(class_="_c24 _50f4").text)
Do this to see if you get something at all.