可用于获取百度贴吧的帖子中的Email地址的Python脚本
来源:互联网 发布:撕衣服软件下载 编辑:程序博客网 时间:2024/06/10 13:02
# _*_ coding:utf-8 _*_
import urllib,urllib2
import re
import time
print('该脚本可用于获取百度贴吧的帖子中的Email地址,获取后保存在D:\Email.txt中,可能需要权限创建这个文件,如可能请以管理员身份运行')
print('网页URL中含有#的有可能失败(#是python的注释标志)')
myUrl=raw_input('请输入网页URL:')
minIndex=int(input('请输入起始页码:'))
maxIndex=int(input('请输入终止页码:'))
firstPattern=re.compile(r'(\?pn=\d+)$')
myUrl=re.sub(firstPattern,'',myUrl)
try:
fp=open(r'D:\Email.txt','a+')
print(time.strftime('%Y-%m-%d-%H-%M-%S:',time.localtime(time.time())))
fp.write(time.strftime('\n%Y-%m-%d-%H-%M-%S:\n',time.localtime(time.time())))
for i in range(minIndex,maxIndex+1):
index=myUrl.rfind(r'?pn=')
if index==-1:
myUrl=myUrl+r'?pn='+str(i)
else:
myUrl=re.sub(firstPattern,r'?pn='+str(i),myUrl)
print(myUrl)
#rep=urllib.Request(myUrl)
rep=urllib2.Request(myUrl)
# rep=urllib.urlopen(myUrl)
response=urllib2.urlopen(rep)
myPage=response.read()
myPage=myPage.decode('utf-8')
myPage=myPage.replace(r'\r\n','')
pattern=re.compile(r'([a-zA-Z0-9]+@[a-zA-Z0-9]+\.?[a-zA-Z0-9]+\.+[a-zA-Z0-9]+)')
result=pattern.findall(myPage)
if result is not None:
for email in result:
print(email)
fp.write(email+';')
else:
print("not found")
fp.close()
print('Suceed!!!')
except Exception as e:
print(e.message)
fp.close()
import urllib,urllib2
import re
import time
print('该脚本可用于获取百度贴吧的帖子中的Email地址,获取后保存在D:\Email.txt中,可能需要权限创建这个文件,如可能请以管理员身份运行')
print('网页URL中含有#的有可能失败(#是python的注释标志)')
myUrl=raw_input('请输入网页URL:')
minIndex=int(input('请输入起始页码:'))
maxIndex=int(input('请输入终止页码:'))
firstPattern=re.compile(r'(\?pn=\d+)$')
myUrl=re.sub(firstPattern,'',myUrl)
try:
fp=open(r'D:\Email.txt','a+')
print(time.strftime('%Y-%m-%d-%H-%M-%S:',time.localtime(time.time())))
fp.write(time.strftime('\n%Y-%m-%d-%H-%M-%S:\n',time.localtime(time.time())))
for i in range(minIndex,maxIndex+1):
index=myUrl.rfind(r'?pn=')
if index==-1:
myUrl=myUrl+r'?pn='+str(i)
else:
myUrl=re.sub(firstPattern,r'?pn='+str(i),myUrl)
print(myUrl)
#rep=urllib.Request(myUrl)
rep=urllib2.Request(myUrl)
# rep=urllib.urlopen(myUrl)
response=urllib2.urlopen(rep)
myPage=response.read()
myPage=myPage.decode('utf-8')
myPage=myPage.replace(r'\r\n','')
pattern=re.compile(r'([a-zA-Z0-9]+@[a-zA-Z0-9]+\.?[a-zA-Z0-9]+\.+[a-zA-Z0-9]+)')
result=pattern.findall(myPage)
if result is not None:
for email in result:
print(email)
fp.write(email+';')
else:
print("not found")
fp.close()
print('Suceed!!!')
except Exception as e:
print(e.message)
fp.close()
0 0
- 可用于获取百度贴吧的帖子中的Email地址的Python脚本
- Python下载百度贴吧帖子里面的图片
- python爬取百度贴吧的帖子
- [百度贴吧] 关于百度贴吧的帖子定位
- python抓取百度贴吧帖子
- Python爬虫实战:百度贴吧帖子
- Python爬取百度贴吧帖子
- python 爬取百度贴吧 帖子
- 如何利用python爬虫技术将百度贴吧上面的帖子名称爬取下来
- Python爬虫实战二:下载百度贴吧帖子内的壁纸
- 简单的python爬虫程序(爬取百度贴吧帖子)
- Python 爬百度贴吧里面的图片 分页分帖子爬取
- Python爬虫实战(五) :下载百度贴吧帖子里的所有图片
- Python爬虫-爬取百度贴吧的帖子并写入文件
- 获取网页内容的email地址
- 获取网页中所有的email地址
- 爬取百度贴吧用户的帖子
- 可用于定时备份Oracle的vbs脚本
- Scut学习笔记(一)
- css中使用!important优先级最高问题
- linux日志logger命令详解
- 定时刷新lucene缓存配置方式
- php读取文件
- 可用于获取百度贴吧的帖子中的Email地址的Python脚本
- poj 1654
- 程序员的30本书——经典中的经典
- LeetCode 40. Combination Sum II
- 安卓获取顶层应用的包名
- android:layout_gravity 和 android:gravity 的区别
- html5 读取本地文件说明和实例
- windows7下makefile例程
- 玩转iOS开发:《iOS设计模式 — 代理模式》