Mohamed Sharkwy Mohamed Sharkwy - 1 year ago 75
Python Question

how to scraping text from hidden div and class using python?

i working on a script for scraping video titles from this webpage
" "
but the proplem is the titles are hidden on the html source page but i can see it if i used the inspector to looking for that

that's my code it's working good with this ("class":"wrap")
but when i used that with the hidden one like "class":"hotvideos-single-trend-title-container" that's did't give me anything on output

#import urllib2
from urllib.request import urlopen
from bs4 import BeautifulSoup
html = urlopen('').read()
soup = BeautifulSoup(html)
print (soup.findAll('div',{"class":"hotvideos-single-trend-title-container"}))

Answer Source

The page is generated/populated by using Javascript.

BeautifulSoup won't help you here, you need a library which supports Javascript generated HTML pages, see here for a list or have a look at Selenium

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download