I am trying to get video links from 'https://www.youtube.com/trendsdashboard#loc0=ind'
. When I do inspect elements, it displays me the source html code for each videos. In source code retrieved using
urllib2.urlopen("https://www.youtube.com/trendsdashboard#loc0=ind").read()
It does not display html source for videos. Is there any otherway to do this?
<a href="/watch?v=dCdvyFkctOo" alt="Flipkart Wish Chain">
<img src="//i.ytimg.com/vi/dCdvyFkctOo/hqdefault.jpg" alt="Flipkart Wish Chain">
</a>
This simple code appears when we inspect elements from browser, but not in source code retrived by urllib
works for me...
IMO I'd use
requests
instead ofurllib
- it's a bit easier to use:Edit
This will get you a list of all
<a></a>
tags with hyperlinks as per your edit. I use the libraryBeautifulSoup
to parse the html: