阅读:1825回复:14
关于安装火狐浏览器驱动的问题
今天看到这个脚本https://githubacom/banhao/scrape-youtube-channel-videos-url
按步骤运行后出现,raise WebDriverException( selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home。 然后找到解决方案说是如此:https://blog.csdn.net/weixin_37185329/article/details/80493281 请问,我配置了python,在使用如下代码from selenium import webdriver browser = webdriver.Firefox() browser.get('http://baidu.com')已经可以打开火狐了,说明前面的配置都没有问题,驱动已经可以了,环境变量也没问题。 但报错是说,我没有安装谷歌浏览器的驱动,可是我用的是火狐呀,大家看看那个i项目测试说火狐可以的呀。 |
|
1楼#
发布于:2021-05-17 14:54
|
|
2楼#
发布于:2021-05-17 12:22
|
|
3楼#
发布于:2021-05-11 17:58
|
|
4楼#
发布于:2021-05-11 09:37
|
|
5楼#
发布于:2021-05-11 09:20
|
|
6楼#
发布于:2021-05-11 09:08
|
|
7楼#
发布于:2021-05-11 08:46
|
|
8楼#
发布于:2021-05-11 07:20
|
|
9楼#
发布于:2021-05-10 20:36
i.get_attribute('href')是获取herf属性,里面是链接。标题存放在title属性里
|
|
10楼#
发布于:2021-05-10 12:23
# scrape-youtube-channel-videos-url.py #_*_coding: utf-8_*_ import sys, unittest, time, datetime import urllib.request, urllib.error, urllib.parse from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.common.exceptions import InvalidArgumentException url = sys.argv[1] channelid = url.split('/')[4] driver=webdriver.Firefox() #driver=webdriver.Chrome() driver.get(url) time.sleep(5) dt=datetime.datetime.now().strftime("%Y%m%d%H%M") height = driver.execute_script("return document.documentElement.scrollHeight") lastheight = 0 while True: if lastheight == height: break lastheight = height driver.execute_script("window.scrollTo(0, " + str(height) + ");") time.sleep(2) height = driver.execute_script("return document.documentElement.scrollHeight") user_data = driver.find_elements_by_xpath('//*[@id="video-title"]') for i in user_data: print(i.get_attribute('href')) link = (i.get_attribute('href')) f = open(channelid+'-'+dt+'.list', 'a+') f.write(link + '\n') f.close |
|
11楼#
发布于:2021-05-10 12:22
|
|
12楼#
发布于:2021-05-10 10:36
|
|
13楼#
发布于:2021-05-10 10:26
你虽然用的是firefox,但脚本代码里指定的是chrome
|
|
14楼#
发布于:2021-05-10 07:57
是不是那个脚本本身需要修改
|
|