python爬取51job中hr的邮箱
作者:lijiao 时间:2022-11-06 14:00:54
本文实例为大家分享了python爬取51job中hr的邮箱具体代码,供大家参考,具体内容如下
#encoding=utf8
import urllib2
import cookielib
import re
import lxml.html
from _ast import TryExcept
from warnings import catch_warnings
f = open('/root/Desktop/51-01.txt','a+')
def read(city):
url = 'http://www.51job.com/'+city
cj = cookielib.MozillaCookieJar()
cookie_support = urllib2.HTTPCookieProcessor(cj)
opener = urllib2.build_opener(cookie_support)
opener.addheaders = [('User-agent','Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0 Iceweasel/38.3.0')]
urllib2.install_opener(opener)
response = urllib2.urlopen(url)
http = response.read()
rex = 'http://jobs.51job.com/hot/.*?html'
value = re.findall(rex, http)
for i in value:
print i
try:
readpage(i)
except:
pass
def readpage(url):
cj = cookielib.MozillaCookieJar()
cookie_support = urllib2.HTTPCookieProcessor(cj)
opener = urllib2.build_opener(cookie_support)
opener.addheaders = [('User-agent','Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0 Iceweasel/38.3.0')]
urllib2.install_opener(opener)
html = urllib2.urlopen(url,timeout = 2).read()
doc = lxml.html.fromstring(html)
rex = r'[\w\.-]+@(?:[A-Za-z0-9]+\.)+[A-Za-z]+'
results = doc.xpath('//div[@class="tmsg inbox"]/div[@class="con_msg"]/div[@class="in"]/p/text()')
for i in results:
xx = re.compile(rex)
for j in xx.findall(i):
print j
f.write(j+'\n')
f.flush()
if __name__ == '__main__':
city_list = ['zhangjiagang','zhanjiang','zhaoqing','zibo']
for i in city_list:
f.write(i+'\n')
f.flush()
try:
read(i)
except:
pass
f.flush()
f.close()
city_list大家自己整理一下,只能帮你们到这里了,谢谢大家的阅读,继续关注脚本之家更多精彩内容。
标签:python,爬取,邮箱
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python实现输出某区间范围内全部素数的方法
2022-04-25 10:04:50
![](https://img.aspxhome.com/file/2023/8/68318_0s.png)
Pytorch统计参数网络参数数量方式
2021-03-13 03:09:04
Python判断变量名是否合法的方法示例
2022-07-31 19:05:12
![](https://img.aspxhome.com/file/2023/1/68411_0s.png)
Python面向对象编程(二)
2022-11-27 23:17:55
python批量处理打开多个文件
2022-10-21 05:26:47
![](https://img.aspxhome.com/file/2023/0/113030_0s.png)
在SQL Server 2008中安装安全审计
2009-02-24 17:22:00
PyTorch小功能之TensorDataset解读
2023-02-26 06:06:27
python里glob模块知识点总结
2022-10-06 18:13:18
Python利用memory_profiler查看内存占用情况
2022-05-24 08:55:29
![](https://img.aspxhome.com/file/2023/0/81810_0s.png)
阿里巴巴技术文章分享 Javascript继承机制的实现
2024-04-30 09:59:16
![](https://img.aspxhome.com/file/2023/1/130881_0s.png)
在JAVASCRIPT中LEFT,RIGHT,MID函数的等价函数
2009-07-21 12:37:00
pytorch GAN生成对抗网络实例
2022-06-30 03:41:27
![](https://img.aspxhome.com/file/2023/7/68397_0s.jpg)
Python通过psd-tools解析PSD文件
2023-05-25 12:08:47
Python编程使用有限状态机识别地址有效性
2023-09-03 00:14:56
![](https://img.aspxhome.com/file/2023/2/133892_0s.jpg)
C#实现复制数据库 C#将A数据库数据转到B数据库
2024-01-23 11:56:09
Echarts实例教程之树形图表的实现方法
2024-04-18 09:44:01
![](https://img.aspxhome.com/file/2023/7/136287_0s.png)
17个asp常用的正则表达式
2008-01-15 18:58:00
Tensorflow加载Vgg预训练模型操作
2023-10-13 10:56:23
![](https://img.aspxhome.com/file/2023/5/80795_0s.jpg)
Python制作CSDN免积分下载器
2021-12-25 03:46:35
![](https://img.aspxhome.com/file/2023/5/71385_0s.jpg)
基于python绘制科赫雪花
2021-01-31 10:13:41
![](https://img.aspxhome.com/file/2023/0/115400_0s.png)