我正在尝试从Youtube下载整个Android开发教程的播放列表。因此,我使用savefrom生成了要下载的播放列表。但问题是该播放列表中有很多视频。因此,我决定编写一个python脚本来简化此工作。但是问题是它使用Java脚本来生成链接,所以我无法使用javascript()来获取生成的链接。
示例:http : //ssyoutube.com/watch? v=AfleuRtrJoA生成下载链接需要5秒钟。
我只想在浏览后5秒钟后获取页面源。
对于这种工作,我找到了一个名为selenium的好包装。
import time
from selenium import webdriver
def savefromnotnet(url):
browser = webdriver.Firefox() # Get local session of firefox
browser.get(url) # Load page
time.sleep(5) # Let the page load, will be added to the API
return browser.page_source()
source = savefromnotnet("http://ssyoutube.com/watch?v=AfleuRtrJoA")
该savefromnotnet
函数将打开Firefox,它将请求url,直到一切正常为止。但是,当我想获取页面源代码时,browser.page_source()
它会显示以下错误。
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 523, in runfile
execfile(filename, namespace)
File "C:\Users\BK\Desktop\Working Folder\Python Temp\temp.py", line 10, in <module>
source = savefromnotnet("http://ssyoutube.com/watch?v=AfleuRtrJoA")
File "C:\Users\BK\Desktop\Working Folder\Python Temp\temp.py", line 8, in savefromnotnet
return browser.page_source()
TypeError: 'unicode' object is not callable
在下一行发生错误。
return browser.page_source()
我认为不需要括号。
return browser.page_source
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句