【问题标题】:How to solve selenium firefox browser is under remote control?如何解决selenium firefox浏览器被远程控制?
【发布时间】:2021-02-25 04:10:32
【问题描述】:

我正在使用 selenium 和 firefox 82.0.3 (64)

代码运行正常,但问题是浏览器处于远程控制之下。

有没有什么办法可以解决或者其他绕过的方法。

我真正想用 selenium 做的是每次执行我的代码时用我定义的新代理打开一个新的 firefox 实例..

提前致谢

这是我的代码片段。

import webbrowser
import time
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager 
from webdriver_manager.firefox import GeckoDriverManager
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

fbgroups = open("all.txt").readlines()
whitelist = open("ntp.txt").readlines()
llf = open('last.txt',"r")

print("Total groups: " + str(len(fbgroups)))
print("Whitelisted: " + str(len(whitelist)))
print("Last: " + str(llf.read()))

# var = int(input('\nStart from: '), 10)
var = 1
myProxy = "us.smartproxy.com:18000"
PROXY_HOST, PROXY_PORT = myProxy.split(":")
while True:
    for a in range (len(fbgroups)-var,0, -1):
        print("Line No: " + str(a+1))
        matched = False

        for b in range (len(whitelist)):
            if whitelist[b].replace('\n', '') in fbgroups[a].replace('\n', ''):
                print("URL"+str(a) + ": Match: " + fbgroups[a])
                matched = True
                break

        if (matched == False):
            lastLink = open('last.txt',"w+")
            lastLink.write(str(len(fbgroups)-a))
            lastLink.close()
        
            print("URL"+ str(a)+ ": " + fbgroups[a])
            
            
            myprofile = webdriver.FirefoxProfile()
            myprofile.set_preference("network.proxy.type", 1)
            myprofile.set_preference("network.proxy.http",PROXY_HOST)
            myprofile.set_preference("network.proxy.http_port",int(PROXY_PORT))
            
            myprofile.set_preference("network.proxy.ssl",PROXY_HOST)
            myprofile.set_preference("network.proxy.ssl_port",int(PROXY_PORT))
            
            myprofile.set_preference("network.proxy.ftp",PROXY_HOST)
            myprofile.set_preference("network.proxy.ftp_port",int(PROXY_PORT))

            user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36'
            myprofile.set_preference("general.useragent.override", user_agent)
            
            myprofile.update_preferences()
            driver = webdriver.Firefox(firefox_profile=myprofile, executable_path=r'C:\Users\Administrator\Downloads\geckodriver.exe')
            
            driver.get(fbgroups[a])
            print("Page Title is : %s" %driver.title)
            input()

    print("ALL DONE :)")

【问题讨论】:

  • 表示浏览器处于远程控制状态,因为浏览器处于远程控制状态。为什么要忽略它?这不是问题,我们希望解决什么问题?
  • @BarışÇiçek ,它只是在客户端还是其他跟踪器可以很容易地理解它在控制之下......
  • 想要隐藏此消息(或使其至少不那么花哨)的最正当理由是为大型演示文稿或营销视频创建演示。它现在的实现方式非常分散注意力,也许是设计使然。

标签: python selenium selenium-webdriver geckodriver browser-automation


【解决方案1】:

您的浏览器处于远程控制之下,这就是为什么它说它处于远程控制之下。

删除该消息的唯一方法是禁用当前配置文件的远程控制。在about:config 中将marionette.enabled 重置为false 并重新启动。

如果您只想设置新配置文件并启动 Firefox,则不需要 selenium。手动创建一个新的配置文件文件夹,使用代理设置添加 prefs.js,并在启动 Firefox 时传递 -profile 选项。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-11-14
    • 2020-10-12
    • 1970-01-01
    • 2011-08-15
    • 2016-02-15
    • 2015-05-12
    • 2016-09-13
    • 1970-01-01
    相关资源
    最近更新 更多