如何解决如何获取硒来移动Google扩展程序设置中的滑块
我正在尝试制作一个Instagram机器人,它有些起作用,但我希望它能够发布图片,我正在使用的扩展名在加载几秒钟后会阻止页面。我在某处发现了一个线程,有人说如果您进入隐身模式,它将解决此问题。问题是我不知道如何使用XPath来移动滑块。
代码:
from selenium import webdriver
from time import sleep
from info import pw
from info import email
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_extension('mhh.crx.crx')
chrome_options.add_argument("--disable-extension")
class InstaBot:
def __init__(self,username,pw):
self.username = username
self.driver = webdriver.Chrome("C:/path stuff/chromedriver.exe",chrome_options=chrome_options)
sleep(1)
self.driver.get("chrome://extensions/?id=jkcghkeldalkgfhgenmcblejihijdpha")
sleep(1)
self.driver.find_element_by_xpath("//a[contains(text(),'crToggle')]")\
.click()
#sleep(2)
self.driver.get("chrome-extension://odlpjhnipdekfkdkadoecooboghijleh/app/index.html")
sleep(2)
self.driver.find_element_by_xpath("//a[contains(text(),'Log in')]")\
.click()
my_bot = InstaBot('tonka_r_us',pw)
图片:
解决方法
要以隐身模式打开Chrome网络驱动程序,最好的方法是使用“选项”。
options = webdriver.ChromeOptions()
options.add_argument("--incognito")
driver = webdriver.Chrome('..\drivers\chromedriver',options=options)
driver.get("https://stackoverflow.com/")
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。