爬虫 抓取论坛 数据 发邮件 两个邮箱

邮件发太多,被QQ邮箱官方给限制了,各种Send Email Failed 550 Connection frequency limited,妈的网易163邮箱也不太好使,没办法暂时两个邮箱一起上,加长时间间隔,多加几次重试,妈蛋先写出来明天跑跑不行再说,哪位大神有高招对付这种邮件发送多了受限的啊,求指教

刚发现新浪也有邮箱,明天不行再加个,话说我们这百度搜索360搜索必应搜索什么垃圾,我博客里的老文章都没有收录,谷歌一搜就出来!是禁止国内蜘蛛爬取?还是技术差距大啊!天天就寻思买广告赚流量热钱啊?NLP做的这么烂,分词分的完全不是重点好么!多少年了中文处理还做的不如谷歌!

#*-coding:utf-8-*-
import urllib2
import re
import smtplib
import time
from email.mime.text import MIMEText

retries1=5
_to = "xxxxxxxxxxxxx@360.cn"

class SendQqMail:
    def getqqmail(self, retries):

        _user = "xxxxxxxxxxxxx@qq.com"
        _pwd = "xxxxxxxxxxxxxxxxxxxxx"

        msg = MIMEText(listitem1[74:-4])
        msg["Subject"] = listitem1[0:42]
        msg["From"] = _user
        msg["To"] = _to

        try:
            time.sleep(30)
            s = smtplib.SMTP_SSL("smtp.qq.com", 465)
            s.login(_user, _pwd)
            s.sendmail(_user, _to, msg.as_string())
            s.quit()
            print "Send QQ Email Success!"
        except smtplib.SMTPException, e:
            print "retry.QQ mail.........,%s" % e
            if retries > 0:
                return self.getqqmail(retries - 1)
            else:
                print "Send QQ Email Falied,%s" % e

class Send163Mail:
    def get163mail(self, retries):

        _user = "xxxxxxxxxxxxxxx@163.com"
        _pwd = "xxxxxxxxxxxxxxxxxxx"

        msg = MIMEText(listitem1[74:-4])
        msg["Subject"] = listitem1[0:42]
        msg["From"] = _user
        msg["To"] = _to

        try:
            time.sleep(30)
            s = smtplib.SMTP_SSL("smtp.163.com", 465)
            s.login(_user, _pwd)
            s.sendmail(_user, _to, msg.as_string())
            s.quit()
            print "Send 163 Email Success!"
        except smtplib.SMTPException, e:
            print "retry.163mail..........,%s" % e
            if retries > 0:
                return self.get163mail(retries - 1)
            else:
                print "Send 163 Email Falied,%s" % e


request = urllib2.Request("http://bbs.360.cn/forum-175-1.html")
response = urllib2.urlopen(request)
buffer = response.read()
getarticlelist = re.compile(r'http://bbs.360.cn/thread-.+-1-1.html" \s?target="_blank" class="s xst".*\s*</a>')
pagemsg = re.findall(getarticlelist,buffer)

print "system start"

while True:
    time.sleep(5)
    request1 = urllib2.Request("http://bbs.360.cn/forum-175-1.html")
    response1 = urllib2.urlopen(request1)
    buffer1 = response1.read()
    getarticlelist1 = re.compile(r'http://bbs.360.cn/thread-.+-1-1.html" \s?target="_blank" class="s xst".*\s*</a>')
    pagemsg1 = re.findall(getarticlelist1,buffer1)
    for listitem1 in pagemsg1:
        if listitem1 in pagemsg:
            pass
        else:
            pagemsg.append(listitem1)
            try:
                qqsendmailer = SendQqMail()
                time.sleep(60)
                qqsendmailer.getqqmail(10)
            except:
                print "QQ mail try five times fail,change 163mail"
                neteasysendmailer = Send163Mail()
                time.sleep(60)
                neteasysendmailer.get163mail(10)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值