论坛: 菜鸟乐园 标题: 从网页中获取email地址的python教本 复制本贴地址    
作者: hksking [hksking]    论坛用户   登录
初学python,写个程序练习正则表达式用的,大家看着玩

import urllib, re
url = ‘http://www.hanweb.com‘
data = urllib.urlopen(url).read()
maillist = re.findall(r‘[0-9a-zA-Z_]{1,}@[0-9a-zA-Z_-]{1,}?.[0-9a-zA-Z_-]{2,}.[a-zA-Z]{0,}.[a-zA-Z]{2,3}‘, data)
count = 0
for i in maillist:
    if count < (len(maillist)-1):
        if maillist[count] == maillist[count+1]:
            del maillist[count+1]
        count = count + 1
maillist.sort()
print ‘The page:‘,url
print ‘included‘, len(maillist), ‘E-mail address:‘
print ‘------------------------------------------‘
for j in maillist:
    print j
print ‘------------------------------------------‘

地主 发表时间: 12/06 19:46

论坛: 菜鸟乐园

20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon

粤ICP备05087286号