【发布时间】:2014-08-25 16:16:10
【问题描述】:
据我所知,LyricWikia 就是这种情况。歌词(example)可以从浏览器访问,但在源代码中找不到(大多数浏览器可以用CTRL + U打开)或使用 Python 阅读网站内容:
from urllib.request import urlopen
URL = 'http://lyrics.wikia.com/Billy_Joel:Piano_Man'
r = urlopen(URL).read().decode('utf-8')
还有测试:
>>> 'Now John at the bar is a friend of mine' in r
False
>>> 'John' in r
False
但是当你选择并查看显示歌词的框的源代码时,可以看到有:<div class="lyricbox">[...]</div>
有没有办法使用 Python 获取 div-element 的内容?
【问题讨论】:
标签: javascript python html parsing