Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我正在使用selenium(python)打开youtube。但是当它打开chrome时,我没有登录_Python_Selenium - Fatal编程技术网

我正在使用selenium(python)打开youtube。但是当它打开chrome时,我没有登录

我正在使用selenium(python)打开youtube。但是当它打开chrome时,我没有登录,python,selenium,Python,Selenium,当selenium打开youtube时,我没有登录,当我尝试登录时,它会显示以下内容: “此浏览器或应用可能不安全。了解详细信息 请尝试使用其他浏览器。如果您已经在使用受支持的浏览器,则可以刷新屏幕,然后重试登录。“ 有办法登录吗 代码如下: from selenium.webdriver.common.keys import Keys from selenium import webdriver browser = webdriver.Chrome("C:\\Users\\Pranav S

当selenium打开youtube时,我没有登录,当我尝试登录时,它会显示以下内容:

“此浏览器或应用可能不安全。了解详细信息 请尝试使用其他浏览器。如果您已经在使用受支持的浏览器,则可以刷新屏幕,然后重试登录。“

有办法登录吗

代码如下:

from selenium.webdriver.common.keys import Keys
from selenium import webdriver


browser = webdriver.Chrome("C:\\Users\\Pranav Sandeep\\Downloads\\chromedriver.exe")

browser.get('https://www.youtube.com')

SearchBar = browser.find_element_by_name("search_query").send_keys("Selenium", Keys.ENTER)

Video = browser.find_element_by_id("video-title")
Video.click()

你需要先登录谷歌,然后才能进入youtube。使用下面的代码

配合使用

注意:将chromedriver置于系统路径中


除此之外,selenium wire还有许多很棒的功能,请查看Github,您需要先登录google,然后才能访问youtube。使用下面的代码

配合使用

注意:将chromedriver置于系统路径中


除此之外,selenium wire还有许多很棒的功能,请查看Github,这是一款精心设计的产品。Selenium使用不同的配置文件启动浏览器。您可以发布代码吗?看起来这是由于远程调试问题造成的?你在Chrome79上吗?参考此线程-这是设计的。Selenium使用不同的配置文件启动浏览器。您可以发布代码吗?看起来这是由于远程调试问题造成的?你在Chrome79上吗?请参阅此线程-
from seleniumwire.undetected_chromedriver.v2 import Chrome, ChromeOptions
import time

options = {}
chrome_options = ChromeOptions()
chrome_options.add_argument('--user-data-dir=hash')
chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument("--incognito")
chrome_options.add_argument("--disable-dev-shm-usage")
# chrome_options.add_argument("--headless")
browser = Chrome(seleniumwire_options=options, options=chrome_options)

browser.get('https://gmail.com')
browser.find_element_by_xpath('//*[@id="identifierId"]').send_keys('your-email')
browser.find_element_by_xpath('//*[@id="identifierNext"]/div/button').click()
time.sleep(5)
browser.find_element_by_xpath('//*[@id="password"]/div[1]/div/div[1]/input').send_keys('you-password')
browser.find_element_by_xpath('//*[@id="passwordNext"]/div/button').click()
time.sleep(5)
browser.get('https://www.youtube.com')