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
#2
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.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Forum Jump:

User Panel Messages

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