python爬取51job中hr的邮箱
2016-05-14 15:54
281 查看
原文链接:https://www.geek-share.com/detail/2674155213.html
#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大家自己整理一下,只能帮你们到这里了。
转载于:https://www.geek-share.com/detail/2674155213.html
相关文章推荐
- python爬取51job中hr的邮箱
- python爬取51job中hr的邮箱
- python爬取51job中hr的邮箱
- python 正则匹配 手机号 QQ号 邮箱 日期 图片
- 【selenium+Python unittest】之发送带中文附件的邮箱
- Python爬虫 抓取大数据岗位招聘信息(51job为例)
- Python创建自己的邮箱应用(2)
- Python 正则表达式 匹配邮箱地址
- Python3.5.3 urllib简单爬取51job
- 新浪sina.cn邮箱注册python版
- Python+Selenium练习篇之1-摘取网页上全部邮箱
- 使用python爬取网页发送到邮箱
- Oracle AWR 报告 每天自动生成并发送邮箱 Python脚本
- 使用python获取邮箱邮件的设置方法
- 用python提取并统计指定邮箱里的特定邮件
- Python之获取邮箱邮件
- 基于python(xpath)的-爬取51job网信息(跳过User-Agent)
- python爬取邮箱
- Python搜索猪场某人邮箱密码
- python正则表达式提取文本中的电话号码和邮箱