程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python+selenium simulated Login new scheme

編輯:Python

I believe that many people will encounter websites that need simulated Login in the process of crawling , Use at this time selenium Simulating the browser has become the preferred solution , But some websites will also be right selenium This plug-in detects , Once discovered, various anti creep mechanisms will appear ( Access denied 、 Verification Code 、 Can't load out 、 Man machine judgment, etc ). Today, let's introduce a scheme that can perfectly bypass this kind of detection , Is the use of Selenium Control the browser that is already open .

1、 Find the locally installed browser startup path , for example Chrome

# windows

C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

# mac

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome

2、 Start... From the command line ChromeDbug Pattern

 # windows

$ C:\Program Files (x86)\Google\Chrome\Application>chrome.exe --remote-debugging-port=9222

# mac

$ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome -remote-debugging-port=9222

# notes :

1. Launch the browser dbug In mode, you need to close all the processes opened by the browser .

2. 9222 Is the default port , It can be modified at will . But don't use ports that are already occupied .

3、 Connection commissioning switch on chrome

options = webdriver.ChromeOptions()
options.debugger_address = "127.0.0.1:9222"
driver = webdriver.Chrome(options=options)

If the above is helpful to you , Please give me a compliment , thank you !


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved