Python Forum
Not able to fetch data from a webpage
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Not able to fetch data from a webpage
#4
I used this code to pick up the data as you suggested -
url_get = requests.get(url)
soup = BeautifulSoup(url_get.content,'lxml')
print(soup.find(class_="_c24 _50f4").text)
In the 'url' variable I am taking the URL of my practice website, and then getting the code of the website in soup variable.

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
RE: Not able to fetch data from a webpage - by sumandas89 - Dec-21-2017, 08:30 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Extract data from a webpage cycloneseb 5 2,997 Apr-04-2020, 10:17 AM
Last Post: alekson
  Get data from a webpage Pedroski55 3 3,163 Mar-02-2019, 03:13 AM
Last Post: Pedroski55
  flask requests display data from api on webpage with javacript pascale 0 2,831 Oct-25-2018, 08:30 PM
Last Post: pascale
  How to fetch latitude,longitude from location and save them separately in db(Django2) PrateekG 0 2,716 Jun-21-2018, 04:40 AM
Last Post: PrateekG
  Unable to fetch product url using BeautifulSoup with Python3.6 PrateekG 6 4,392 Jun-05-2018, 05:49 PM
Last Post: PrateekG
  How do I fetch values from db to Select Options using Flask? progShubham 2 17,874 Jul-25-2017, 05:52 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

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