简体   繁体   中英

Python website source extraction

i'm using urllib2 to download the source of a website, but something is going wrong. The source comes from this website: http://www.starfm.com/ All i want to do is to download the entire html , and then parse it extracting the "Now playing" section from the website.

But, when i download the source with this code

response = urllib2.urlopen('http://www.starfm.com/')
html = response.read()
a = open("C:\\users\\Leonardo\\Desktop\\source.txt","w")
a.write(html)
a.close()

the final source does not show the current artist in the website's "Now playing" section.

Why? What should i do?

Thanks so much in advance.

-Leonardo

"now playing" comes from javascript, maybe it loads that info on the onload() event , in this case your code is just reading the content.

maybe this question will help you

Get page generated with Javascript in Python

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM