python 中的selenium 无头浏览器的bug

option = webdriver.ChromeOptions()
         option.add_argument('--start-maximized')  # 最大化
         option.add_argument('--headless')  # 无界面
         self.driver = webdriver.Chrome(chrome_options=option)

         self.driver.get("https://www.qichacha.com/")
         time.sleep(5)
         response=self.driver.page_source.encode("utf-8")
         print(response)
         self.driver.find_element_by_id('searchkey').send_keys("baidu")
         self.driver.find_element_by_id('V3_Search_bt').click()
         print("asdadsad")
         

clipboard.png

为啥这里返回的内容是一个网址呢?我用有头浏览器就可以正常返回!

阅读 3.3k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题