python 爬去拉钩测试招聘信息
2023-09-27 14:27:40 时间
代码如下:
1 #coding:utf-8 2 import time 3 import urllib.request 4 from bs4 import BeautifulSoup 5 file=open(r'meituancde.txt','w') 6 def get_url(i): 7 url='https://www.lagou.com/zhaopin/ceshi/%s/?filterOption=%s'%(i,i) 8 return url 9 def get_html(i): 10 headers={ 11 'User-Agent':'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36' 12 } 13 response=urllib.request.Request(url=get_url(i),headers=headers) 14 html=urllib.request.urlopen(response).read().decode('utf-8') 15 sopu=BeautifulSoup(html) 16 return sopu 17 def parse(i): 18 soup=get_html(i) 19 me=soup.findAll('',{'class':'money'}) #工资 20 me1=soup.findAll('',{'class':'format-time'})#发布时间 21 me2=soup.findAll('',{'class':'li_b_r'})#福利 22 me3=soup.findAll('',{'data-lg-tj-id':'8F00'})#公司名字 23 meitu={} 24 i=0 25 for title in me: 26 meitu['gongzi'] =me[i].text 27 for jianjie in me1: 28 meitu['发布时间']=me1[i].text 29 for sellum in me2: 30 meitu['福利']=me2[i].text 31 for pire in me3: 32 meitu['公司名称']=me3[i].text 33 i+=1 34 print(meitu) 35 if len(meitu) !=0: 36 file.write(str(meitu)) 37 file.write("\n") 38 file.close 39 if __name__ == '__main__': 40 for i in range(1,31):
41 parse(i)
结果图:
相关文章
- 职场经验:学习Python到什么地步才可以做自动化测试?
- python实现基于RPC协议的接口自动化测试
- 基于Selenium+Python的web自动化测试框架
- Python 和Java 哪个更适合做自动化测试?
- Pytest 自动化测试 / [码尚教育]Python全栈自动化VIP课程对标大厂标准(挑战年薪40万)
- 一道有趣的大厂测试面试题,你能用 Python or Shell 解答吗?
- python+appium自动化测试获取短信+图片验证码
- python中tldextract用法详解
- 测试一些利用PYTHON完成中英文翻译的效果
- 157 python网络编程 - 多进程服务器
- 全网最详细,Python接口自动化测试接口加密实战,框架撸码.......
- 4年功能测试,我一进阶python接口自动化测试,跳槽拿了20k......
- 【测试开发】python系列教程:python反射
- web自动化测试:Selenium+Python基础方法封装
- 【Python】【日志】log/logging
- 【Python】自动化测试请求文件上传接口
- 【Python】+pip超时
- 获取电影影评+数据可视化 | Python+requests+re+WordCloud
- 《Python Cookbook(第2版)中文版》——1.3 测试一个对象是否是类字符串
- python之__call__方法
- 快速部署Python应用:Nginx+uWSGI配置详解
- python使用pexpect与screen进行交互控制启动ffmpeg
- python接口测试:如何将A接口的返回值传递给B接口
- 【Python】几种测试框架对比-unittest
- 【Python养成】:正则表达式测试案例 —— 1
- 这你能相信?有人用Java、Python、C、C++、Go、JS等等各种语言把所有算法实现了一遍
- Python matplotlib subplot
- 用Python求偶数和