您现在的位置是:主页 > news > 深圳专业网站建设制作/泉州百度竞价推广

深圳专业网站建设制作/泉州百度竞价推广

admin2025/6/7 13:21:56news

简介深圳专业网站建设制作,泉州百度竞价推广,建立的意思,嘉兴网站建设的地方吾生于乙亥年,于世虚度二十春秋是也。小生不才,明知文拙脑蠢,却喜挥笔泼墨,畅叙幽情。小生不才,愿分享以己所学,不足之处望多指教。 人才网是目前非常热门的一个网站之一,属于前程无忧下的一个典…

深圳专业网站建设制作,泉州百度竞价推广,建立的意思,嘉兴网站建设的地方吾生于乙亥年,于世虚度二十春秋是也。小生不才,明知文拙脑蠢,却喜挥笔泼墨,畅叙幽情。小生不才,愿分享以己所学,不足之处望多指教。 人才网是目前非常热门的一个网站之一,属于前程无忧下的一个典…

       吾生于乙亥年,于世虚度二十春秋是也。小生不才,明知文拙脑蠢,却喜挥笔泼墨,畅叙幽情。小生不才,愿分享以己所学,不足之处望多指教。

    人才网是目前非常热门的一个网站之一,属于前程无忧下的一个典型网站之一。本文主要是以正则表达式及BeautifulSoup库进行爬取数据。使用Python代码获取数据,同时使用re正则表达式匹配自己想要的信息,最后对数据进行预处理并保存到本地进行分析。

还是老规矩,简单拆分:

获取网页源码,同时转换字符编码。同时编写遍历函数,确保能爬取所有页面的数据。

#导入urllib.request库,对网页进行请求解析
import urllib.request
import re #导入正则表达式
#打开网址
content=urllib.request.urlopen(url)
#读取源代码并转换为Unicode
html=content.read().decode('gbk')
#返回网页
return html

采用正则表达式匹配想要的信息,re.S匹配换行符,

#采用正则表达匹配职位吗、薪资、公司名称和发布日期,re.S匹配换行符reg = re.compile(r'class="t1 ">.*? <a target="_blank" title="(.*?)".*? <span class="t2"><a target="_blank" title="(.*?)".*?<span class="t3">(.*?)</span>.*?<span class="t4">(.*?)</span>.*? <span class="t5">(.*?)</span>',re.S)

保存到本地。

for j in range(1,76):print("正在爬取第"+str(j)+"页数据。。。")#调用源码html=get_content(j)for i in get(html):#print(i[0]+'\t'+i[1]+'\t'+i[2]+'\t'+i[3]+'\t'+i[4])with open('C:/Users/USER/Desktop/biyeshejidaimai/zhaopinxinxi.xls','a',encoding='utf-8') as f:f.write(i[0]+'\n')f.close()
print("写入完成.....")

代码不是太多,也不是很难,下面就是完整代码展示:

# -*- coding:utf-8 -*-
import urllib.request
import re#获取网页源码
def get_content(page):url='https://search.51job.com/list/260200,000000,0000,00,9,99,%25E8%25AE%25A1%25E7%25AE%2597%25E6%259C%25BA,2,'+str(page)+'.html?lang=c&stype=&postchannel=0000&workyear=99&cotype=99&degreefrom=99&jobterm=99&companysize=99&providesalary=99&lonlat=0%2C0&radius=-1&ord_field=0&confirmdate=9&fromType=&dibiaoid=0&address=&line=&specialarea=00&from=&welfare='#打开网址content=urllib.request.urlopen(url)#读取源代码并转换为Unicodehtml=content.read().decode('gbk')#返回网页return htmldef get(html):#采用正则表达式匹配想要的信息,re.S匹配换行符reg = re.compile(r'class="t1 ">.*? <a target="_blank" title="(.*?)".*? <span class="t2"><a target="_blank" title="(.*?)".*?<span class="t3">(.*?)</span>.*?<span class="t4">(.*?)</span>.*? <span class="t5">(.*?)</span>',re.S)items=re.findall(reg,html)return items#多个页面处理
for j in range(1,76):print("正在爬取第"+str(j)+"页数据。。。")#调用源码html=get_content(j)for i in get(html):#print(i[0]+'\t'+i[1]+'\t'+i[2]+'\t'+i[3]+'\t'+i[4])with open('C:/Users/USER/Desktop/biyeshejidaimai/zhaopinxinxi.xls','a',encoding='utf-8') as f:f.write(i[0]+'\n')f.close()
print("写入完成.....")

结果展示:

根据数据表明,所爬取得数据有2912条,发布日期人才网表明的是12月28号到2月21号。从上面可以清楚地看到招聘的职位、公司名称、地址、薪资和发布日期。

好了,目前就到这里了