from selenium import webdriver
from lxml import etree
import re
import time
from selenium.webdriver.common.by import By
import csv
import requests
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import pymysql
class LagouSpider(object):
def __init__(self):
self.driver_path = r'D:\cd\chromedriver.exe'
self.driver = webdriver.Chrome(executable_path=self.driver_path)
self.url = 'https://www.lagou.com/jobs/list_%E5%AE%A2%E6%9C%8D?city=%E6%B7%B1%E5%9C%B3&cl=false&fromSearch=true&labelWords=&suginput='
self.positions = []
self.stauts = 0
self.cursor=''
self.db=''
def run(self):
#给傻缺链接数据库
self.db = pymysql.connect("127.0.0.1", "root", "111111", "kedou")
self.cursor = self.db.cursor(pymysql.cursors.DictCursor)
self.driver.get(self.url)
while True:
WebDriverWait(driver=self.driver, timeout=10).until(
EC.presence_of_element_located((By.XPATH, "//div[@class='pager_container']/span[last()]"))
)
# print(self.driver.page_source)
s
拉勾网爬取客服信息并记录到数据库(只获取公司名称)下一篇会根据公司名筛选
最新推荐文章于 2022-06-05 14:01:09 发布