Python 3.0 实现定时时监控12306 火车票

 

                            Python 3.0 实现定时时监控12306 火车票

 

本文章内容将完整发表在公众号: 程序员开发者社区, 欢迎关注,后台回复:资源,有惊喜!

 

王小涛同学的 2015年的已经不好用了,在其基础上改了改

这里提供个 2016的 可以在python3.0 环境下运行的:

看代码:

import urllib.request as request
import http.cookiejar as cookiejar
import re
import ssl
import os
import smtplib
from email.mime.text import MIMEText
import time

user = 'xxxx'  # 登陆邮箱
pwd = ''  # 邮箱密码
to = ['']  # 发送的邮箱
with open('D:\\Python源码\\city.txt', 'r') as f:
    a = f.read()
station = re.compile(u'\w+:(.+?):(\w+):\d').findall(a)
dic1 = {}
for b in range(0, len(station)):
    dic1[station[b][0]] = station[b][1]


def gethtml(geturl):
    cj = cookiejar.LWPCookieJar()
    cookiejarsupport = request.HTTPCookieProcessor(cj)
    opener = request.build_opener(cookiejarsupport, request.HTTPHandler)
    #handler = request.HTTPBasicAuthHandler()

    

你可能感兴趣的:(Python)