Python:提取网页中的电子邮箱


  1. import requests, re

    #regex = r"([a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+)"
    #这个正则表达式过滤掉了qq邮箱
    regex = r"([a-zA-Z0-9_.+-]+@[a-pr-zA-PRZ0-9-]+.[a-zA-Z0-9-.]+)"
    #基于隐私,使用了“XXXXXXXXXXXXXX”
    url = 'http://blog.sina.com.cn/s/XXXXXXXXXXXXXXXXXX.html'
    html = requests.get(url).text
    #print(html)
    emails = re.findall(regex,html)
    i = 0
    for email in emails:
    i += 1
    if i < 16:
    print("{} :{}".format(i,email))

原文地址:https://www.cnblogs.com/adolfmc/p/8376903.html