自如网房源释放自动提醒爬虫

自如网房源释放自动提醒爬虫
主要功能为配置中未释放的房源释放后自动发邮件提醒,避免错过抢不到房子

使用方法:
_user = “发送邮箱”
_pwd = “发送邮箱的密码”
_to = “接收邮箱”

打开想抢的配置中的房源,
把代码中:http://www.ziroom.com/z/vr/60138527.html
改为你想抢的房子页面的链接再运行即可,有条件的可以放服务器上 nohup 24小时跑

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

def get163mail(retries):
    _user = "sendemail@email.com"
    _pwd = "password"
    _to = "receiveemail@email.com"
    msg = MIMEText(" quickly!!!!")
    msg["Subject"] = "quicklyquickly!!!!"
    msg["From"] = _user
    msg["To"] = _to

    try:
        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 get163mail(retries - 1)
        else:
            print "Send 163 Email Falied,%s" % e

print ("starting")
session = requests.session()
while 1:
    try:
        response_ziroom = session.get("http://www.ziroom.com/z/vr/60138527.html",
                                      headers={
                                          'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:48.0) Gecko/20100101 Firefox/48.0'})
        webpage_result = re.compile(r'title="配置中"')
        analyze_result = re.search(webpage_result, response_ziroom._content)
        if analyze_result:
            print "still processing! wait!"
        print time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
        time.sleep(30)
        else:
            get163mail(5)
        print time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
        print "quick get it!"
        break
    except:
        print "fuck socket is closed, retry..."
        time.sleep(120)
        continue
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值