python用selenium chromedriver爬蟲下載數據總出現這個問題

CSDN問答 2022-01-08 03:59:17 阅读数:526

python selenium chromedriver

 

萌新提問:為什麼出現這個問題,是不讓我IP爬蟲了嗎,有什麼解决方法呢,這是個內網的 網址,貼出程序請大神們幫忙看看,,感謝

 

def chrome_init(today_dir,str_time1,str_time2): option = webdriver.ChromeOptions() prefs = {'profile.default_content_settings.popups': 0, 'download.default_directory': os.path.join(today_dir,'data_'+str_time1)} option.add_experimental_option('prefs', prefs) driver = webdriver.Chrome(executable_path=r'C:\Users\m1886\AppData\Local\Google\Chrome\Application\chromedriver.exe',options=option) driver.implicitly_wait(30) # 隱性等待,最長等30秒 while True: driver.get("http://130.17.182.33:18889/cms/welcome.action") # driver.get("http://130.17.182.33:8080/cms/welcome.action") time.sleep(1) if has_element(driver): break #S輸入用戶名密碼登錄 driver.find_element_by_id("nameinput").send_keys(Keys.CONTROL,"a") driver.find_element_by_id("nameinput").send_keys("chengjr1") driver.find_element_by_id("pwdinput").send_keys("chengjr1#") driver.find_element_by_class_name("login_btn").click() #E輸入用戶名密碼登錄 while True: driver.get("http://130.17.182.33:8080/cms/report/brokenstationnum/brokenNumReport!initSearchReport.action") # driver.get("http://119.188.254.28:18889/cms//report/brokenstationnum/brokenNumReport!initSearchReport.action") time.sleep(1) if has_element(driver): break return driverdef has_element(d,tagname='div'): try: d.find_elements_by_xpath('//'+tagname) return True except: return False



采納答案:

調試看運行到哪一步出現這個錯誤,大概率是提交用戶名密碼後,服務端出錯


版权声明:本文为[CSDN問答]所创,转载请带上原文链接,感谢。 https://gsmany.com/2022/01/202201080359166514.html