current position:Home>Run selemium in the script and fill in the verification code. The statement will not be executed after the browser is started

Run selemium in the script and fill in the verification code. The statement will not be executed after the browser is started

2022-01-26 23:53:03 CSDN Q & A

I'm doing a bidding web crawler
http://bs.gdggzy.org.cn/osh-web/project/projectbulletin/bulletinList?queryType=1&orgCode=gd&tradeTypeId=GovernmentProcurement&tradeItemId=zf_res_bulletin
Every once in a while, you need to fill in the verification code to enter the website , So I think every time I run scrapy First judge whether the website needs to fill in the verification code , if necessary , Just use selenium Screenshot upload verification code identification platform to pass the verification , And get the current web page cookie Come on, next parse Pass on
my selenium The code is written in start_request Medium

    def start_requests(self):        for url in self.start_urls:            driver_path = 'C:/Users/AppData/Local/Google/Chrome/Application/chromedriver.exe'            options = webdriver.ChromeOptions()            options.add_experimental_option('excludeSwitches', ['enable-automation'])            browser = webdriver.Chrome(executable_path=driver_path, options=options)            browser.get(url=url)            WebDriverWait(browser, 10, 0.2).until(lambda x: x.find_element_by_xpath("//head//title"))             The next step is to get the screenshot of the verification code 、 To upload pictures 、 Operation of entering verification code       

When I read the log, I open the browser after executing the above paragraph , Close seconds after the browser displays the page , The following code did not execute , Why is that ?




Refer to the answer 1:

You put a in the code print() Let's see where we're going




Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201262353011492.html

Random recommended