webdriver 파이썬에서 크롬에 대한 프록시를 설정합니다. 이것은 FF에서 작동합니다. Chrome에서 이와 같은 프록시를 설정하는 방법은 무엇인가요? 이 exmaple을 찾았지만별로 도움이되지 않습니다. 스크립트를 실행할 때 아무 일도 일어나지 않습니다 (Chrome 브라우저가 시작되지 않음). 나를 위해 일하는는 어떻게 내가이 코드를 사용하고
답변
from selenium import webdriver
PROXY = "23.23.23.23:3128" # IP:PORT or HOST:PORT
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=%s' % PROXY)
chrome = webdriver.Chrome(chrome_options=chrome_options)
chrome.get("http://whatismyipaddress.com")
브라우저를 다시 시작하지 않고도 방법이 있습니까? thx – 176coding
from selenium import webdriver
from selenium.webdriver.common.proxy import *
myProxy = "86.111.144.194:3128"
proxy = Proxy({
'proxyType': ProxyType.MANUAL,
'httpProxy': myProxy,
'ftpProxy': myProxy,
'sslProxy': myProxy,
'noProxy':''})
driver = webdriver.Firefox(proxy=proxy)
driver.set_page_load_timeout(30)
driver.get('http://whatismyip.com')
질문에 대답하지 않습니다. – Collin
크롬 - Chrome에 대한 질문이 –
그 ...
from selenium import webdriver
PROXY = "23.23.23.23:3128" # IP:PORT or HOST:PORT
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--proxy-server=http://%s' % PROXY)
chrome = webdriver.Chrome(chrome_options=chrome_options)
chrome.get("http://whatismyipaddress.com")
프록시에 필요한 경우 사용자 이름/비밀번호를 어떻게 추가합니까? – desmond
나는 같은 일에 문제가 있었다. ChromeOptions은 생각했던 것처럼 원하는 기능과 통합되지 않았기 때문에 매우 이상합니다. 정확한 세부 정보를 잊어 버렸지 만 기본적으로 ChromeOptions는 원하는 기능을 수행했는지 여부에 따라 기본적으로 특정 값으로 재설정됩니다.
def __init__(self, executable_path="chromedriver", port=0,
chrome_options=None, service_args=None,
desired_capabilities=None, service_log_path=None, skip_capabilities_update=False):
"""
Creates a new instance of the chrome driver.
Starts the service and then creates new instance of chrome driver.
:Args:
- executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH
- port - port you would like the service to run, if left as 0, a free port will be found.
- desired_capabilities: Dictionary object with non-browser specific
capabilities only, such as "proxy" or "loggingPref".
- chrome_options: this takes an instance of ChromeOptions
"""
if chrome_options is None:
options = Options()
else:
options = chrome_options
if skip_capabilities_update:
pass
elif desired_capabilities is not None:
desired_capabilities.update(options.to_capabilities())
else:
desired_capabilities = options.to_capabilities()
self.service = Service(executable_path, port=port,
service_args=service_args, log_path=service_log_path)
self.service.start()
try:
RemoteWebDriver.__init__(self,
command_executor=self.service.service_url,
desired_capabilities=desired_capabilities)
except:
self.quit()
raise
self._is_remote = False
:
나는 나를 ChromeOptions
의 합병증에 대해
변화 /selenium/webdriver/chrome/webdriver.py에 다음 코드를 걱정하지 않고 내 자신의 DICT을 지정할 수 있습니다 다음 원숭이 패치를했다
변경된 사항은 모두 "skip_capabilities_update"kwarg입니다. 지금 나는 내 자신의 dict을 설정하기 위해 이렇게한다.
capabilities = dict(DesiredCapabilities.CHROME)
if not "chromeOptions" in capabilities:
capabilities['chromeOptions'] = {
'args' : [],
'binary' : "",
'extensions' : [],
'prefs' : {}
}
capabilities['proxy'] = {
'httpProxy' : "%s:%i" %(proxy_address, proxy_port),
'ftpProxy' : "%s:%i" %(proxy_address, proxy_port),
'sslProxy' : "%s:%i" %(proxy_address, proxy_port),
'noProxy' : None,
'proxyType' : "MANUAL",
'class' : "org.openqa.selenium.Proxy",
'autodetect' : False
}
driver = webdriver.Chrome(executable_path="path_to_chrome", desired_capabilities=capabilities, skip_capabilities_update=True)
- 1. 내가이 자바 코드를 사용하고
- 2. 내가이 코드를 사용하고 때없는 IllegalAccessError
- 3. 는 어떻게 다음 코드를 사용하고 쿼리 문자열
- 4. 는 어떻게 다음 코드를 사용하고 JQuery와
- 5. 어떻게 내가이 코드를 연주하고있어 사용자
- 6. 어떻게 내가이 코드 조각을 사용하고 C#을
- 7. 는 어떻게 자바와 XML 파일을 구문 분석이 코드를 사용하고
- 8. 는 어떻게 멀티 스레딩 구현이 코드를 사용하고 JFrame의
- 9. 어떻게 내가이 같은 예를 사용하고 C#
- 10. 것은 내가이 튜토리얼을 사용하고
- 11. 내가이 사용하고 그럴
- 12. 어떻게 내가이 코드를 가지고 pluginType이 항목
- 13. 어떻게 내가이 코드를 사용하여 시도 ADO
- 14. 어떻게 내가이 코드를 가지고 변수 JQuery와
- 15. 는 어떻게 코드를 C#을
- 16. 내가이 코드를 파이썬
- 17. 내가이 PHP 코드를 C#
- 18. 내가이 작은 코드를 그루비
- 19. 는 아무도 내가이 오류가
- 20. 는 내가이 오류가
- 21. 내가이 jQuery를 툴팁 플러그인을 사용하고
- 22. 내가이 슬라이더를 사용하고 jQuery를 슬라이더
- 23. 은 어떻게 링크 아래에 주어진 코드를 사용하고
- 24. 어떻게 다음 코드를 사용하고 XAML 코드
- 25. 는 내가이 일을 수행 할
- 26. 는 어떻게 AzureDirectory와 루씬 .NET 2.9.4을 사용하고
- 27. 는 어떻게 GWTP와 GWT2.3를 사용하여 사용하고 GWT
- 28. 는 어떻게 개미 1.8.2를 사용하고 Ant 빌드
- 29. 어떻게 내가이 같은 일부 코드를 찾을 CABasicAnimation 키 패스
- 30. 내가이 웹 사이트 다운로드 httrack를 사용하고
미안하지만 'Firefox' 라인을 Chrome과 동일하게 변경 했는가? 코드를 게시 할 수 있습니까? –
또한 "아무 일도 없다"는 것은 무엇을 의미합니까? 오류 메시지가 있습니까? 어떤 종류의 종료 상태입니까? –
Internet Explorer에서 프록시를 설정 한 경우 스크립트가 작동하지 않는 것으로 나타났습니다 (FF가 열리고 있지만 driver.get ("google.com/";)에서는 실패 함). 오류 메시지가 없으므로 연결을 거부합니다. Internet Explorer에서 프록시 설정을 사용할 수없는 경우 스크립트가 작동합니다. – sarbo