In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces selenium how to implement js and bypass webdriver monitoring related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe you will have something to gain after reading this selenium how to implement js and bypass webdriver monitoring articles, let's take a look.
Selenium executes js advantages: environmental barriers to directly calling browsers: bypass selenium monitoring principles: # execute js code bro.execute_script ('js code') Common selenium monitoring methods normal login window.navigator.webdriver = = undefined automated window.navigator.webdriver = = true, there are some other iconic strings (different browsers may vary) Common feature strings are as follows: webdriver_ _ driver_evaluate _ _ webdriver_evaluate _ _ selenium_evaluate _ _ fxdriver_evaluate _ driver_unwrapped _ _ webdriver_unwrapped _ _ selenium_unwrapped _ fxdriver_unwrapped _ Selenium_IDE_Recorder _ selenium calledSelenium _ WEBDRIVER_ELEM_CACHE ChromeDriverw driver-evaluate webdriver-evaluate selenium-evaluate webdriverCommand webdriver-evaluate-response _ webdriverFunc _ _ webdriver_script_fn _ $webdriverAsyncExecutor _ _ lastWatirAlert _ _ lastWatirConfirm _ _ lastWatirPrompt $chrome_asyncScriptInfo $cdc_asdjflasutopfhvcZLmcfl_ after learning about this feature You can determine whether selenium is currently used in the browser client JS by detecting these feature strings, and append the test results to subsequent requests, so that the server can identify and intercept subsequent requests. Commonly used to bypass selenium monitoring 1 normal login window.navigator.webdriver = = undefined automation window.navigator.webdriver = = truefrom selenium import webdriveroptions = webdriver.ChromeOptions () # this step is very important and is set to developer mode Prevent the use of Seleniumoptions.add_experimental_option ('excludeSwitches', [' enable-automation']) # to stop loading images options.add_experimental_option ("prefs", {"profile.managed_default_content_settings.images": 2}) browser = webdriver.Chrome (options=options) browser.get ('https://www.taobao.com/') often bypasses selenium monitoring 2from selenium import webdriverchrome_options = webdriver.ChromeOptions () chrome_options.add_experimental_option (' debuggerAddress') '127.0.0.1 TR 9222') browser=webdriver.Chrome (executable_path=r'C:\ Users\ TR\ AppData\ Local\ Google\ Chrome\ Application\ chromedriver.exe',chrome_options=chrome_options) browser.get (' http://www.zhihu.com') terminal enters the following instruction: chrome.exe-- remote-debugging-port=9222-- user-data-dir= "D:\ cdsf" (requires Google driver under the system environment variable Then run the program) remote-debugging-port is the port debuggerAddress specified in your code Executable_path is your Google driver location; user-data-dir can simply specify a directory that often bypasses selenium monitoring 31. Use remote debug mode of chrome combined with selenium to remotely crawl chrome without carrying fingerprint information step:-start chrome manually using debug mode to enter the installation path of chrome, for example, chrome is installed under C:\ program\ google\ chrome.exe-enter the installation path of chrome-execute command: # make sure that the port is not occupied To turn off the firewall, user-data-dir is used to indicate the path to the configuration file chrome.exe-- remote-debugging-port=9222-- user-data-dir= "points to any empty folder" 2. After startup, create a new python file and run the code: import requestsfrom selenium import webdriverchrome_options = "C:\ Users\ Administrator\ AppData\ Local\ Google\ Chrome\ Application\ chrome.exe" chrome_options = webdriver.ChromeOptions () chrome_options.add_experimental_option ('debuggerAddress' '10.8.13.95chrome_options=chrome_options 9222') browser = webdriver.Chrome (chrome_options=chrome_options) browser.get ("https://www.zhihu.com/signup?next=%2F")# chrome.exe-- remote-debugging-port=9222-- user-data-dir=" D:\ moni ") this is not the selenium that simulates the commonly used bypass selenium monitoring 4def selenium (js): option = webdriver.ChromeOptions () # option.add_argument ('-- headless') Option.add_experimental_option ('useAutomationExtension' False) option.add_experimental_option ('excludeSwitches', [' enable-automation']) bro = webdriver.Chrome (executable_path='./chromedriver', options=option) # pop-up browser To give the browser-driven address # Open the page priority js,execute_cdp_cmd bro.execute_cdp_cmd ("Page.addScriptToEvaluateOnNewDocument", {"source": "" Object.defineProperty (navigator, 'webdriver') {get: () = > undefined}) ""}) bro.implicitly_wait (10) bro.get ('https://www.toutiao.com/') time.sleep (5) print (bro.page_source) # get the html code bro.execute_script (js) input () returned from the page about "how selenium executes js And bypass webdriver monitoring "this article ends here." Thank you for reading! I believe you all have a certain understanding of "how selenium executes js and bypasses webdriver monitoring". If you want to learn more, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.