实现追磨铁上小说功能,追磨铁小说,最近一直在磨铁上追书,可
实现追磨铁上小说功能,追磨铁小说,最近一直在磨铁上追书,可
最近一直在磨铁上追书,可是受不了天天刷新网页,网上抄了几段代码,实现了简单的追书功能,原理很简单,抓取章节网页,正则匹配章节信息,发送到设置好的邮箱,为方便识别,邮件题目是最新的章节。
未来打算匹配最新章节再发送邮件,如果可以,实现抓取章节内容,不过此为收费网站,估计很难实现。
目前采用python3实现,希望未来部署在云服务器上例如GAE,不过貌似不支持python3,希望以后解决,或者降级使用
import urllib.requestimport reimport timeimport smtplibfrom email.mime.text import MIMEText#要发给谁,这里发给1个人mailto_list=["aaa@gmail.com",""]######################设置服务器,用户名、口令以及邮箱的后缀mail_host="smtp.163.com"mail_user="aaa"mail_pass="aaa"mail_postfix="163.com"######################def send_mail(to_list,sub,content): #to_list:发给谁 #sub:主题 #content:内容 #send_mail("aaa@126.com","sub","content") me = "aaa <aaa@163.com>" msg = MIMEText(content) msg['Subject'] = sub msg['From'] = me msg['To'] = ";".join(mailto_list) try: s = smtplib.SMTP() s.connect(mail_host) s.login(mail_user,mail_pass) s.sendmail(me, mailto_list, msg.as_string()) s.close() return True except Exception as e: print(str(e)) return False#获取输入的帖子单页htmldef getHtml2(url2): html2=urllib.request.urlopen(url2).read().decode('utf-8') return html2#抽取图片相关列表,并下载图片def gettopic(html2): reg2=r'第\\w+节\\s\\w*' topiclist=re.findall(reg2,html2) x=0 y='' #print(topiclist) #限制下载的图片数 for topicurl in topiclist: x+=1 y=y+topicurl+'\\n' print(topicurl) print(x) if send_mail(mailto_list,'屌丝道士最新章节 '+topicurl,y): print('发送成功') else: print('发送失败') return topicurl#调用函数html2=getHtml2('http://www.motie.com/book/24336/chapter')topicurl=gettopic(html2)print('采集完成!')#该片段来自于http://byrx.net
相关内容
- Python的map、reduce和filter以及list comprehension(列表推导)
- 生成随机密码python 窗口程序,python窗口,随机码主窗口
- 计算阶乘,,[Python]代码pr
- 通过动态代理生成基于gfwlist的动态代理脚本,,[Python
- 删除注释并编译,删除注释编译,[Python]代码#!
- 由域名获取该域名的ip地址,获取域名ip地址,[Python]代码
- 百度指定行业seo市场竞争度查询工具,seo市场竞争,[P
- 福彩3D号码预测,福彩3d预测,[Python]代码im
- 采用右递归的超简单八皇后解决,采用递归皇后,[Pyth
- 人人自动@所有好友,人人好友,[Python]代码#
评论关闭