Google驱动Python爬微博处理首页警告弹窗

写博客记录编程的美好时光;《google驱动Python爬微博处理首页警告弹窗》 截图如下:
这里写图片描述
关键词: Python,selenium,微博弹窗

前提背景: 有人说,这有毛难的呀,不就设置一下google浏览器的高级设置嘛,那么麻烦;我说: 锤子你试试看; 试了再来看这篇文章哈~~Selenium每一次打开微博的时候是需要重置设置的,是从根目录打开的,所以有

些网友那样设置是不行滴~~
处理思路:
1.设置好Google的驱动(具体我就不说了自己去看社区的另外作者文章配置)
2.设置好google安装路径
3.关键处理部分是,每一次访问微博官网的时候我们就把google 重新配置一次。(这样虽然处理时间多了一点点,但是也是一个思路嘛~ 莫喷)
4.上码坐稳了!起飞

这里写代码片
#coding:utf-8
from selenium import webdriver
from selenium.webdriver.common.alert import Alert
import time
options=webdriver.ChromeOptions()
options.add_argument('--user-data-dir=C:\\Users\\Administrator\\AppData\\Local\\Google\\Chrome\\User Data') 
driver=webdriver.Chrome(chrome_options=options)
driver.get('https://weibo.com/')
time.sleep(5)
print("-------------------------------------------------------")
driver.find_element_by_class_name("W_input").send_keys("Beautiful ChengDu normal university")
print(" input conetent and click")
driver.find_element_by_class_name("ficon_search").click()

猜你喜欢

转载自blog.csdn.net/qq_35619526/article/details/82110637