使用selenium和openpylx抓取大学生招聘信息

使用Python的Selenium和BeautifulSoup库,配合openpyxl,从安徽大学生就业服务平台抓取并整理公司招聘信息,包括公司名称、招聘职位、专业要求等,最后将数据存储到Excel文件中。
摘要由CSDN通过智能技术生成
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)):
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值