from selenium import webdriver from bs4 import BeautifulSoup from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By from openpyxl.utils import get_column_letter import re import openpyxl from openpyxl.styles import Font import datetime times=datetime.datetime.now() times=times.strftime('%Y_%m_%d_%H时%M分')#以时间日期为工作表的文件名,便于管理 present_time=times url = "http://ahut.ahbys.com/jobfair.html"#安徽大学生就业服务平台的url地址 '''option=webdriver.ChromeOptions()#用于隐藏网页窗口 option.add_argument('--headless')''' driver = webdriver.Chrome() driver.get(url) driver.maximize_window() WebDriverWait(driver,30).until(EC.visibility_of_element_located((By.ID,'recordercount')))#等待条件,使用selenium访问就业服务平台,设置等待条件 websource=driver.page_source websource=BeautifulSoup(websource,'html.parser')#使用selenium+Beautifulsoup结合导出的所有的原网页信息 websource=str(websource)#转变为字符串的格式,不然正则无法抓取 company_name_url=re.findall('<td.*?white-space:nowrap;padding-left:10px; height:50px;line-height:50px.*?href=\"(.*?)\".*?>(.*?)</a>',websource,re.S)#使用正则表达去抓取公司招聘信息 company_url=[]#构造空列表,用于存放公司url的信息 for i in range(len(company_name_url)):
使用selenium和openpylx抓取大学生招聘信息
最新推荐文章于 2024-08-13 20:32:54 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)