声明 : 本篇仅学习使用,不到将其用于其他途径.
import time,pymongo
#先导入驱动,我这边用的谷歌的
from selenium import webdriver
#显式延时等待
from selenium.webdriver.support.wait import WebDriverWait
#对网页上元素是否存在,可点击等等进行判断,一般用于断言或与WebDriverWait配合使用
from selenium.webdriver.support import expected_conditions as ec
##实现by功能,该功能用于指定查找方式
from selenium.webdriver.common.by import By
#需要用到多线程
from threading import Thread
client = pymongo.MongoClient()
coll = client['Tencent']['job']
#这里是屏蔽网站对webdriver的检测
options = webdriver.ChromeOptions()
options.add_argument('--disable-blink-features=AutomationControlled')
browser = webdriver.Chrome(options=options)
#延时等待,最长等待10秒
wait = WebDriverWait