我尝试将selenium
用于chromedriver
这样的网页:
http://shironet.mako.co.il/artist?type=lyrics&lang=1&prfid=202&wrkid=2473
问题是Selenium
总是等到页面加载完毕(例如那里的youtube
播放器)。
我只对html
来源感兴趣,所以我不想等这么久。
如何让我的程序不要等待?我正在使用python
。
(我使用selenium
导致urllib
没有为此网站工作)
答案 0 :(得分:0)
几乎没有可能的解决方案:
1)由于您没有澄清您的意思urllib didnt work for this website
,您可以尝试使用python-requests
库:
pip install requests
/ cmd
Terminal
url = "http://shironet.mako.co.il/artist?type=lyrics&lang=1&prfid=202&wrkid=2473"
page_source = requests.get(url).content
2)尝试使用Firefox Preferences
:
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
profile.set_preference("media.autoplay.enabled", False);
driver = webdriver.Firefox(profile)
3)更粗鲁的方法是禁用页面上的Javascript
(我不确定你是否真的需要这个用于描述目的)
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
profile.set_preference("javascript.enabled", False);
driver = webdriver.Firefox(profile)
但要小心,因为它可以从页面源中删除一些必需的媒体文件