python最简单的爬取邮箱地址
来源:互联网 发布:黎明杀机mac能不能玩 编辑:程序博客网 时间:2024/05/16 19:17
http://www.jb51.net/article/57161.htm
#!/usr/bin/env python#-*- coding:utf-8 -*-import reimport sysdef getIPAddFromFile(fobj): regex = re.compile(r'\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b', re.IGNORECASE) ipadds = re.findall(regex, fobj) print ipadds return ipaddsdef getPhoneNumFromFile(fobj): regex = re.compile(r'1\d{10}', re.IGNORECASE) phonenums = re.findall(regex, fobj) print phonenums return phonenumsdef getMailAddFromFile(fobj): regex = re.compile(r"\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}\b", re.IGNORECASE) mails = re.findall(regex, fobj) print mails return mailsdef getUrlFromFile(fobj): regex = re.compile(r"http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+", re.IGNORECASE) urls = regex.findall(fobj) print urls return urlsdef main(FilefilePath): fobj = open(FilefilePath, 'rb').read() urllist = getUrlFromFile(fobj) mailList = getMailAddFromFile(fobj) phoneNum = getPhoneNumFromFile(fobj) ipaddlist = getIPAddFromFile(fobj)if __name__ == '__main__': main(sys.argv[1])
</pre><pre name="code" class="python">
</pre><pre name="code" class="python">
# -*- coding: utf-8 -*- import reimport urllibdef getHtml(url): page = urllib.urlopen(url) html = page.read() return htmldef getImg(html): reg = r'src="(.+?\.jpg)" pic_ext' #p=re.compile('[^\._-][\w\.-]+@(?:[A-Za-z0-9]+\.)+[A-Za-z]+$|^0\d{2,3}\d{7,8}$|^1[358]\d{9}$|^147\d{8}') regex = re.compile(r"\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}\b", re.IGNORECASE) imgre = re.compile(regex) imglist = re.findall(regex,html) print imglist return imglist #x=0 #for imgurl in imglist: #urllib.urlretrieve(imgurl,'%s.jpg' % x) #x=x+1 html = getHtml("http://tieba.baidu.com/p/3827945043")print getImg(html)
0 0
- python最简单的爬取邮箱地址
- 最简单的邮箱地址的链接
- 最简单的Python爬取web图片代码
- Python爬虫爬取百度搜索结果——邮箱地址
- python简单正则的爬取
- python爬虫----简单的图片爬取
- python 爬取网页的最基础三种方法
- 利用JS简单的验证邮箱地址
- Python爬取简单网页
- 简单的python爬虫(爬取百度百科词条)
- 简单的python爬取网页字符串内容并保存
- python简单爬虫爬取队列的实现
- python爬取亚马逊简单的书籍信息
- Python简单爬取蚂蚁窝首页的图片
- 利用python对网页和图片的简单爬取
- Python爬虫学习笔记(1):简单的图片爬取
- Python,分析爬取简单waterfall型网页的部分内容
- Js-最严谨的校验邮箱地址的正则表达式
- Android EditView 设置键盘搜索,回车
- update语句的语法与原理
- Android程序:使用ViewPager实现app引导页效果
- 图像检索:Bag-of-words模型简介
- Android ADB server didn't ACK * failed to start daemon * 简单有效的解决方案
- python最简单的爬取邮箱地址
- codeforce #129
- js输出一个字符串中出现次数最多的字符
- QTP中DataTable类型参数化步骤举例
- smart_stl::deque相关总结
- docker 常用命令
- Bag of Features (BOF)图像检索算法
- 理解Javascript_09_Function与Object
- 今天更新sdk,遇到了更新下载失败问题: