Python Forum
web scraping extract particular Div section
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
web scraping extract particular Div section
#7
Larz60+ Wrote:you need:
results = soup.find('div', {'class': '_2RngUh'})
Don't need that @Larz60+,i do not use the dictionary call way anymore.
Because you can just copy class name direct for source code and just add class_ to make it work.
Example:
from bs4 import BeautifulSoup

html = '<div class="cities">London</div>'
soup = BeautifulSoup(html, 'lxml')
Usage:
# Only add _
>>> tag = soup.find(class_="cities")
>>> tag.text
'London'

>>> # A dictionary call need more changing of what is organically is and also need a div tag 
>>> tag = soup.find('div', {'class': 'cities'})
>>> tag.text
'London'
Reply


Messages In This Thread
RE: web scraping extract particular Div section - by snippsat - May-12-2020, 03:24 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Web scraping read particular section AjayBachu 4 3,114 May-08-2020, 07:33 AM
Last Post: AjayBachu
  how to print out all the link <a> under each h2 section using beautifulsoup HenryJ 2 12,527 Feb-02-2018, 02:55 AM
Last Post: HenryJ
  Monitor a section of a webpage for changes yeto 1 3,175 Dec-05-2017, 08:09 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