diff --git a/12306login/.idea/workspace.xml b/12306login/.idea/workspace.xml index 27fcf94..e4cab73 100644 --- a/12306login/.idea/workspace.xml +++ b/12306login/.idea/workspace.xml @@ -12,9 +12,10 @@ - - + + + @@ -38,8 +39,8 @@ - - + + @@ -50,11 +51,23 @@ - - + + - + + + + + + + + + + + + + @@ -63,9 +76,11 @@ - - - + + + + + @@ -73,8 +88,18 @@ - - + + + + + + + + + + + + @@ -110,6 +135,8 @@ back_train_date query_from_station_name get + 出票成功 + 尝试提交订单... @@ -129,8 +156,10 @@ @@ -143,7 +172,8 @@ @@ -173,34 +203,6 @@ - - - + + + - - - - - + + + + + - - - - - + + + + + @@ -589,16 +591,15 @@ - - + - + - + @@ -647,40 +648,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -696,7 +663,9 @@ - + + + @@ -713,7 +682,7 @@ - + @@ -741,7 +710,9 @@ - + + + @@ -749,7 +720,9 @@ - + + + @@ -759,7 +732,9 @@ - + + + @@ -795,7 +770,9 @@ - + + + @@ -830,22 +807,6 @@ - - - - - - - - - - - - - - - - @@ -864,14 +825,6 @@ - - - - - - - - @@ -895,10 +848,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -907,11 +920,11 @@ - - + + - + diff --git a/12306login/agency/__init__.py b/12306login/agency/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/12306login/agency/agency_tools.py b/12306login/agency/agency_tools.py new file mode 100644 index 0000000..212b1e6 --- /dev/null +++ b/12306login/agency/agency_tools.py @@ -0,0 +1,77 @@ +#encoding=utf8 +import socket +import urllib +import urllib2 +from bs4 import BeautifulSoup + + +class proxy: + def __init__(self): + self.proxy_list = [] + self.proxy_filter_list = [] + + def get_proxy(self): + """ + 获取未加工代理列表 + :return: + """ + User_Agent = 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0' + header = {} + header['User-Agent'] = User_Agent + + for i in range(1, 10): + url = 'http://www.xicidaili.com/nn/'+str(i) + req = urllib2.Request(url, headers=header) + res = urllib2.urlopen(req).read() + + soup = BeautifulSoup(res, "html.parser") + ips = soup.findAll('tr') + + for x in range(1, len(ips)): + ip = ips[x] + tds = ip.findAll("td") + ip_temp = tds[1].contents[0] + ":" + tds[2].contents[0] + self.proxy_list.append(ip_temp) + + def filter_proxy(self): + """ + 将不可用IP剔除 + :return: + """ + socket.setdefaulttimeout(1) + f = open("./proxy_list", "w") + url = "http://ip.chinaz.com/getip.aspx" + proxy_num = 0 + for proxy in self.proxy_list: + proxy_temp = {"http://": proxy} + try: + urllib.urlopen(url, proxies=proxy_temp).read() + write_proxy = proxy+"\n" + f.write(write_proxy) + proxy_num += 1 + except Exception, e: + print ("代理链接超时,去除此IP:"+ proxy) + print e + continue + print("总共可使用ip量为{}个".format(proxy_num)) + + def get_filter_proxy(self): + """ + 读取该可用ip文件 + :return: 可用ip文件list + """ + f = open("./proxy_list", "r") + lins = f.readlines() + for i in lins: + p = i.strip("\n") + self.proxy_filter_list.append(p) + return self.proxy_filter_list + + def main(self): + self.get_proxy() + self.filter_proxy() + self.get_filter_proxy() + +if __name__ == "__main__": + a = proxy() + a.main() \ No newline at end of file diff --git a/12306login/agency/proxy_list b/12306login/agency/proxy_list new file mode 100644 index 0000000..d5eb239 --- /dev/null +++ b/12306login/agency/proxy_list @@ -0,0 +1,900 @@ +116.117.184.215:8080 +115.220.5.103:808 +222.95.20.76:808 +222.94.147.0:808 +183.153.40.131:808 +180.110.4.172:808 +115.203.84.49:808 +114.221.238.150:808 +120.83.103.14:808 +220.166.96.90:82 +116.226.90.12:808 +139.224.237.33:8888 +113.120.233.217:8118 +222.220.48.54:8998 +58.209.151.126:808 +119.4.134.124:808 +117.91.138.93:808 +175.155.25.9:808 +171.13.85.167:37610 +42.48.40.115:808 +180.76.154.5:8888 +49.86.62.115:808 +113.69.165.195:808 +117.91.138.201:808 +42.48.40.115:808 +119.165.249.13:8118 +219.139.190.188:808 +221.229.47.64:808 +175.155.231.208:808 +117.91.138.31:808 +218.86.128.21:8118 +116.255.153.137:8082 +220.160.10.233:808 +221.229.44.159:808 +221.229.46.40:808 +175.155.152.186:808 +202.108.2.42:80 +110.73.13.234:8123 +119.5.0.58:808 +222.134.171.222:808 +222.95.22.20:808 +115.213.202.253:808 +113.234.167.130:8118 +218.58.226.140:808 +119.5.1.42:808 +115.213.228.232:808 +183.153.5.159:808 +175.155.24.52:808 +175.155.244.212:808 +115.215.70.167:808 +222.94.149.15:808 +180.110.5.143:808 +113.69.63.159:808 +115.213.176.237:808 +117.43.0.105:808 +122.245.71.59:808 +119.5.217.143:808 +180.118.243.175:808 +113.57.48.234:8118 +113.69.37.179:808 +180.119.65.82:808 +183.153.17.87:808 +122.241.72.203:808 +119.5.1.57:808 +49.86.62.175:808 +122.245.65.48:808 +111.183.212.15:8118 +222.95.23.48:808 +120.83.97.110:808 +119.5.1.22:808 +110.153.16.148:8998 +175.155.24.48:808 +182.42.38.85:808 +110.83.46.150:808 +115.220.7.76:808 +175.155.245.84:808 +180.110.132.112:808 +27.159.125.23:8118 +121.237.143.77:808 +111.206.163.235:80 +121.61.107.94:808 +171.38.129.207:8123 +175.155.25.23:808 +119.7.78.55:808 +222.85.39.94:808 +119.5.169.61:808 +175.155.247.9:808 +119.5.0.38:808 +119.5.0.44:808 +175.155.25.32:808 +119.5.0.4:808 +123.169.91.39:808 +115.209.29.188:808 +171.38.161.4:8123 +218.64.92.250:808 +114.239.145.68:808 +14.109.102.12:8998 +119.7.77.130:808 +175.155.240.134:808 +115.220.1.20:808 +119.7.77.130:808 +175.155.240.134:808 +115.220.1.20:808 +113.58.234.56:808 +115.202.166.37:808 +114.239.145.214:808 +122.245.71.170:808 +60.178.84.54:808 +115.220.148.242:808 +221.229.45.134:808 +27.159.124.121:8118 +117.91.138.191:808 +119.5.0.20:808 +183.153.52.164:808 +218.64.154.164:808 +113.69.38.41:808 +115.207.4.184:808 +36.249.27.218:808 +114.239.252.29:808 +222.95.23.12:808 +60.167.20.148:808 +114.230.121.154:808 +119.0.170.7:8998 +140.224.76.58:808 +110.73.5.126:8123 +125.106.93.210:808 +115.203.87.213:808 +114.230.232.183:808 +183.150.138.103:808 +119.5.1.62:808 +60.184.110.48:808 +222.94.150.242:808 +115.202.182.40:808 +115.202.190.170:808 +175.155.246.135:808 +115.220.145.129:808 +1.192.247.78:8118 +119.7.75.246:808 +119.130.34.36:8118 +175.155.227.13:808 +221.229.47.109:808 +123.169.85.64:808 +59.62.119.220:808 +175.155.24.84:808 +125.118.70.222:808 +180.118.240.195:808 +123.55.92.49:808 +175.155.25.28:808 +113.69.62.201:808 +175.155.25.3:808 +115.202.183.74:808 +122.245.65.68:808 +119.5.0.100:808 +171.38.24.118:8123 +123.170.255.62:808 +222.94.150.0:808 +222.95.18.16:808 +218.73.143.244:35134 +115.220.145.51:808 +110.73.196.43:8123 +123.55.188.212:808 +220.160.10.198:808 +122.10.190.66:808 +115.215.68.77:808 +110.73.8.183:8123 +113.70.147.24:808 +115.213.204.95:808 +113.70.149.90:808 +221.229.44.70:808 +221.229.45.209:808 +115.202.181.181:808 +114.239.145.94:808 +119.5.0.111:808 +125.112.175.67:27141 +121.226.187.32:808 +218.64.93.41:808 +60.167.135.44:808 +119.4.135.231:808 +112.84.59.176:808 +60.178.84.179:808 +119.5.0.155:808 +171.13.36.125:808 +121.40.108.76:80 +113.122.139.172:808 +113.122.3.142:808 +113.122.153.239:808 +182.42.41.149:808 +119.7.73.5:808 +221.229.47.69:808 +116.28.121.144:808 +175.155.137.168:808 +175.170.188.214:8118 +121.205.72.77:42563 +182.35.210.97:808 +113.121.250.192:808 +115.215.70.250:808 +175.155.241.131:808 +115.215.69.86:808 +1.58.69.67:8118 +221.229.45.81:808 +113.69.253.78:808 +222.95.19.49:808 +171.38.187.113:8123 +116.196.3.165:29669 +115.202.183.22:808 +125.106.129.253:808 +125.106.130.159:808 +115.202.177.111:808 +171.13.36.250:808 +221.229.44.160:808 +115.203.74.2:808 +59.62.124.190:808 +175.155.24.99:808 +115.207.6.171:808 +125.122.61.235:808 +117.43.41.141:808 +114.238.116.89:808 +183.128.127.188:808 +120.83.122.62:808 +125.118.66.163:808 +115.215.71.162:808 +117.84.113.115:808 +115.220.144.107:808 +175.155.142.73:808 +115.202.184.98:808 +183.153.24.0:808 +115.220.149.238:808 +171.38.131.144:8123 +123.163.162.9:808 +113.121.169.32:808 +115.203.76.90:808 +222.33.192.238:8118 +175.167.63.82:808 +110.177.149.204:808 +114.239.2.179:808 +125.89.123.75:808 +123.169.90.198:808 +115.203.90.156:808 +183.153.15.141:808 +175.155.240.246:808 +171.13.37.193:808 +115.220.1.134:808 +175.155.241.114:808 +183.153.15.153:808 +115.215.70.142:808 +115.220.5.173:808 +183.153.2.37:808 +115.220.151.69:808 +115.213.255.89:808 +180.115.12.104:30427 +60.184.117.13:808 +175.155.245.182:808 +183.153.21.190:808 +113.123.127.193:808 +175.155.246.245:808 +112.85.11.241:808 +175.155.247.223:808 +113.69.254.227:808 +113.69.255.233:808 +117.43.0.48:808 +115.203.174.6:808 +180.110.19.130:808 +119.7.74.253:808 +113.121.42.15:808 +113.121.249.211:808 +171.13.36.147:808 +222.85.50.211:808 +125.118.68.17:808 +115.220.3.33:808 +27.184.53.113:8118 +114.239.2.67:808 +120.90.6.92:8080 +171.38.36.225:8123 +115.213.230.100:808 +171.38.94.214:8123 +222.134.169.96:808 +218.65.64.2:808 +171.38.185.205:8123 +115.213.229.36:808 +114.99.18.146:808 +116.28.109.213:808 +27.24.176.2:808 +121.61.111.98:808 +115.220.7.249:808 +183.153.9.82:808 +115.203.94.117:808 +115.203.88.124:808 +123.161.153.166:29353 +117.86.21.18:808 +119.5.0.29:808 +114.99.7.186:808 +114.99.20.20:808 +183.153.10.225:808 +114.99.0.202:808 +101.66.90.16:808 +123.179.130.203:80 +175.155.25.17:808 +182.90.92.78:80 +115.220.149.51:808 +122.228.179.178:80 +182.90.92.78:80 +115.220.149.51:808 +122.228.179.178:80 +115.212.82.156:808 +115.203.173.72:808 +175.155.245.153:808 +125.89.120.85:808 +121.61.110.226:808 +114.239.145.187:808 +49.65.151.37:808 +222.85.50.186:808 +221.229.45.93:808 +140.224.76.121:808 +60.167.132.147:808 +222.94.146.127:808 +125.89.122.21:808 +115.202.174.62:808 +114.239.146.55:808 +111.72.244.191:808 +175.155.24.10:808 +60.184.172.93:808 +175.155.25.37:808 +114.238.144.250:808 +110.73.7.0:8123 +183.153.15.242:808 +110.73.48.157:8123 +115.220.6.127:808 +221.229.46.158:808 +175.155.240.117:808 +221.229.46.25:808 +175.155.240.63:808 +111.72.229.119:808 +60.178.84.148:808 +221.229.46.164:808 +114.239.147.25:808 +115.220.144.69:808 +111.72.154.3:808 +115.203.89.133:808 +110.73.38.201:8123 +218.64.93.164:808 +175.155.25.19:808 +119.5.0.22:808 +122.241.73.32:808 +125.89.124.6:808 +115.220.7.119:808 +115.220.145.168:808 +221.229.18.104:808 +36.248.132.82:808 +115.209.31.156:808 +175.155.24.21:808 +36.99.207.163:808 +222.85.50.218:808 +183.128.125.143:808 +115.213.177.58:808 +123.169.39.80:808 +140.224.76.202:45153 +122.242.222.233:21357 +110.73.51.33:8123 +119.5.0.53:808 +203.93.0.115:80 +110.73.11.6:8123 +175.155.24.18:808 +125.118.67.165:808 +119.5.0.6:808 +115.202.161.52:808 +175.155.138.215:808 +171.38.180.17:8123 +125.106.250.244:808 +180.110.4.247:808 +221.229.46.105:808 +60.178.87.44:808 +175.155.25.34:808 +115.203.86.219:808 +119.120.59.123:808 +175.155.25.43:808 +115.210.77.25:24482 +49.86.62.145:808 +110.73.36.55:8123 +111.72.245.79:808 +218.64.93.42:808 +122.245.67.127:808 +123.55.184.140:808 +171.12.139.67:808 +125.89.122.244:808 +125.118.69.238:808 +115.220.147.58:808 +119.5.1.54:808 +171.38.171.117:8123 +218.64.93.114:808 +117.43.0.244:808 +171.38.176.142:8123 +171.38.37.230:8123 +114.239.145.229:808 +117.43.44.154:808 +115.220.6.116:808 +175.155.24.111:808 +171.38.166.73:8123 +59.62.113.217:808 +120.83.96.111:808 +171.38.212.44:8123 +113.121.241.13:808 +119.5.1.87:808 +222.95.22.115:808 +113.69.62.174:808 +112.194.216.46:808 +125.106.131.239:808 +121.204.102.157:808 +119.254.84.90:80 +221.229.47.61:808 +175.155.24.45:808 +115.220.150.224:808 +221.229.44.19:808 +106.14.226.108:80 +115.221.121.222:27015 +115.220.149.248:808 +110.244.132.223:80 +113.58.234.89:808 +171.39.102.144:8123 +221.229.44.137:808 +180.118.243.224:808 +123.55.178.237:808 +115.213.250.150:808 +182.42.40.195:808 +175.155.24.60:808 +113.121.22.216:808 +115.220.150.103:808 +59.62.86.51:808 +106.46.3.179:808 +115.203.87.150:808 +175.155.24.17:808 +119.5.1.125:808 +175.155.24.57:808 +119.5.1.78:808 +119.5.0.5:808 +117.91.138.48:808 +171.38.186.121:8123 +175.155.247.101:808 +218.64.93.134:808 +222.134.171.35:808 +123.169.90.15:808 +115.215.69.69:808 +115.215.69.87:808 +123.169.90.224:808 +220.160.10.89:808 +115.215.71.195:808 +115.220.1.137:808 +175.155.24.96:808 +60.184.173.177:808 +60.167.22.73:808 +182.126.92.166:8118 +122.193.14.110:80 +115.202.185.97:808 +123.55.176.25:808 +123.55.178.223:808 +115.213.200.182:808 +123.55.179.224:808 +121.206.22.218:808 +115.203.85.134:808 +175.155.241.99:808 +218.64.92.202:808 +175.155.241.108:808 +60.26.142.110:8118 +115.220.146.51:808 +115.220.3.250:808 +175.155.24.80:808 +36.99.207.229:808 +153.36.13.190:808 +115.215.71.34:808 +110.73.32.173:8123 +182.88.166.229:8123 +49.86.62.196:808 +60.167.132.224:808 +119.29.136.14:808 +171.38.76.78:8123 +60.167.22.203:808 +180.118.242.135:808 +119.7.77.227:808 +221.229.45.208:808 +49.81.219.162:808 +182.45.177.141:808 +153.36.51.100:808 +115.220.144.49:808 +175.155.246.131:808 +153.36.79.171:808 +221.229.45.163:808 +175.155.244.89:808 +115.213.237.69:808 +175.155.243.9:808 +115.220.146.74:808 +175.155.68.99:808 +115.203.76.43:808 +125.122.48.128:808 +175.155.242.181:808 +119.5.32.81:808 +36.249.24.67:808 +218.64.93.43:808 +119.5.0.82:808 +175.155.25.7:808 +117.43.0.86:808 +110.73.30.248:8123 +113.123.55.133:808 +115.203.75.193:808 +175.155.241.139:808 +115.192.73.24:808 +180.110.133.88:808 +59.62.120.187:808 +115.220.0.115:808 +115.213.233.223:808 +175.155.141.235:808 +119.5.221.79:808 +175.155.241.151:808 +115.215.70.73:808 +121.226.170.98:45471 +110.73.32.90:8123 +115.203.67.241:808 +61.178.238.122:63000 +115.202.190.132:808 +115.220.7.77:808 +59.62.99.47:808 +60.167.21.79:808 +117.43.1.200:808 +182.38.23.198:808 +115.220.145.87:808 +182.90.6.121:80 +119.0.193.155:8998 +115.220.5.39:808 +222.94.145.155:808 +60.167.22.28:808 +175.155.244.101:808 +114.238.23.155:808 +60.167.23.29:808 +115.220.4.243:808 +182.45.176.218:808 +115.220.150.27:808 +182.38.104.192:808 +119.5.0.124:808 +113.121.44.92:808 +175.155.138.221:808 +182.38.172.68:8118 +175.169.125.76:80 +183.153.10.230:808 +27.158.27.192:8118 +180.118.242.180:808 +222.95.17.14:808 +222.94.146.245:808 +112.194.43.254:808 +175.155.25.62:808 +110.189.222.159:808 +175.155.24.38:808 +106.120.78.129:80 +140.224.76.198:808 +115.220.147.151:808 +182.90.78.255:8123 +123.169.87.87:808 +117.91.138.120:808 +113.58.235.168:808 +59.62.86.132:808 +175.155.243.46:808 +119.5.0.2:808 +222.85.39.167:808 +175.155.25.12:808 +218.64.92.166:808 +106.90.88.31:8123 +113.69.38.170:808 +113.69.253.236:808 +119.5.0.47:808 +218.64.92.216:808 +125.106.128.17:808 +60.167.132.22:808 +171.38.243.179:8123 +171.38.78.75:8123 +171.38.5.21:8123 +60.184.172.44:808 +114.238.22.42:808 +115.202.179.70:808 +125.89.122.177:808 +121.61.108.42:808 +125.89.120.54:808 +36.99.207.250:808 +114.238.62.229:808 +175.155.25.25:808 +113.69.167.143:808 +175.155.25.44:808 +119.7.72.39:808 +122.245.64.151:808 +123.163.82.226:808 +116.20.97.13:808 +175.155.24.2:808 +125.89.122.149:808 +119.5.0.24:808 +119.5.221.30:808 +180.118.243.144:808 +180.110.4.198:808 +115.220.3.189:808 +119.5.0.54:808 +123.55.94.133:808 +183.153.22.174:808 +221.175.137.24:80 +221.229.47.251:808 +115.220.4.9:808 +222.94.146.81:808 +115.207.81.54:808 +180.118.240.118:808 +113.69.60.144:808 +115.203.88.223:808 +115.215.70.58:808 +36.249.30.120:808 +182.88.42.232:8123 +60.178.87.224:808 +120.83.101.230:808 +121.61.103.168:808 +36.249.28.185:808 +221.229.45.204:808 +115.220.1.108:808 +59.62.126.145:808 +182.44.247.65:808 +59.62.123.154:808 +119.7.75.46:808 +113.69.164.231:808 +101.205.14.230:808 +175.155.241.194:808 +120.76.79.24:80 +117.91.138.209:808 +115.202.173.234:808 +117.43.0.183:808 +113.69.255.7:808 +121.61.105.219:808 +175.155.246.215:808 +123.169.85.115:808 +175.155.242.83:808 +115.220.2.65:808 +113.76.195.214:808 +119.7.76.29:808 +218.64.93.219:808 +125.106.248.80:808 +36.249.25.117:808 +175.155.25.26:808 +171.13.36.109:49546 +121.206.32.21:808 +222.95.20.13:808 +115.215.69.140:808 +119.5.217.189:808 +125.106.131.245:808 +61.188.24.97:808 +218.64.93.3:808 +113.69.253.223:808 +175.155.242.206:808 +222.95.20.25:808 +60.23.46.245:8118 +183.153.27.56:808 +112.85.209.32:808 +175.155.138.72:808 +60.184.174.136:808 +101.205.83.6:808 +114.230.234.23:808 +59.62.165.170:808 +119.5.0.52:808 +115.220.147.126:808 +115.220.145.204:808 +119.7.217.169:808 +175.155.25.8:808 +123.55.191.17:808 +119.5.1.28:808 +115.192.96.8:808 +115.207.5.185:808 +175.155.24.59:808 +115.192.248.169:808 +113.69.61.246:808 +183.153.22.101:808 +115.213.250.47:808 +121.31.85.70:8123 +60.179.232.53:3128 +182.45.176.47:808 +120.40.132.196:28269 +60.184.175.123:808 +175.155.243.49:808 +114.103.38.34:808 +221.229.45.13:808 +183.128.44.99:808 +114.230.99.232:808 +175.155.246.219:808 +123.55.186.240:808 +125.106.92.229:808 +60.167.133.143:808 +175.155.24.53:808 +60.178.87.127:808 +115.220.149.22:808 +121.226.154.84:808 +115.220.144.98:808 +123.169.87.94:808 +115.202.186.59:808 +115.202.162.92:808 +115.215.71.28:808 +183.153.20.72:808 +175.155.242.81:808 +183.166.170.53:808 +36.99.206.247:808 +113.121.253.210:808 +113.58.233.119:808 +60.5.36.26:80 +113.121.253.210:808 +113.58.233.119:808 +60.5.36.26:80 +222.94.146.203:808 +222.94.145.189:808 +113.123.36.119:808 +221.229.45.158:808 +115.220.7.38:808 +121.61.103.187:808 +115.220.7.63:808 +121.206.19.141:808 +121.206.34.195:808 +121.206.34.243:808 +121.206.18.116:808 +121.206.18.227:808 +121.62.139.8:808 +175.155.240.41:808 +115.215.71.211:808 +175.155.245.169:808 +119.4.12.70:808 +115.220.146.225:808 +115.220.149.203:808 +115.220.3.164:808 +114.239.151.217:808 +121.61.102.56:808 +175.155.247.57:808 +49.86.62.113:808 +115.151.3.218:808 +175.155.243.96:808 +122.5.132.74:808 +121.61.102.120:808 +175.155.244.86:808 +113.58.232.103:808 +59.62.164.207:808 +114.99.10.100:808 +114.239.144.85:808 +182.34.16.113:808 +115.203.82.22:808 +223.245.197.9:808 +121.61.99.251:808 +60.178.86.85:808 +119.4.12.254:808 +114.239.2.218:808 +115.220.4.103:808 +113.69.255.95:808 +175.155.71.39:808 +125.92.33.242:808 +175.155.247.60:808 +115.151.4.182:808 +117.60.85.228:808 +222.85.39.125:808 +123.169.86.206:808 +36.99.206.254:808 +115.220.150.208:808 +175.155.240.87:808 +115.220.146.231:808 +61.157.198.66:8080 +175.155.246.212:808 +114.230.120.82:41753 +175.155.247.100:808 +120.42.123.131:21697 +182.45.52.80:808 +222.85.50.29:808 +182.45.41.201:808 +221.229.47.68:808 +115.220.2.161:808 +113.58.233.2:808 +1.194.191.60:808 +175.155.244.211:808 +115.220.5.64:808 +171.36.61.110:8123 +110.73.3.191:8123 +183.33.171.73:8118 +171.36.63.100:8123 +175.155.238.240:808 +113.121.46.90:808 +183.140.73.253:808 +125.122.94.165:808 +123.163.162.69:808 +114.239.149.210:808 +113.69.212.169:808 +59.62.118.96:808 +114.99.17.46:808 +221.229.44.14:808 +117.43.1.246:808 +123.163.162.43:808 +60.184.174.58:808 +221.229.46.49:808 +222.85.50.14:808 +122.241.73.113:808 +60.167.21.220:808 +218.64.92.161:808 +115.207.7.2:808 +171.37.158.198:8123 +115.220.1.118:808 +115.220.151.110:808 +218.64.92.170:808 +115.220.1.55:808 +114.238.23.56:808 +175.155.245.109:808 +122.241.75.50:808 +123.54.194.48:808 +180.115.11.163:23651 +180.118.242.210:808 +111.76.227.93:808 +110.73.53.37:8123 +218.64.93.135:808 +60.178.85.32:808 +115.220.144.38:808 +175.155.246.53:808 +221.229.46.56:808 +123.169.87.144:808 +115.220.3.42:808 +175.155.243.90:808 +113.12.65.154:1337 +121.31.147.83:8123 +115.202.176.26:808 +218.64.93.86:808 +182.88.46.80:8123 +60.184.193.111:808 +180.110.17.203:808 +115.203.68.119:808 +115.220.144.153:808 +175.155.152.56:808 +171.38.229.10:8123 +121.61.107.252:808 +121.226.168.63:808 +171.38.162.131:8123 +218.64.93.177:808 +123.169.34.81:808 +175.155.24.6:808 +112.84.112.62:80 +121.31.174.88:8123 +115.46.66.230:8123 +115.46.66.220:8123 +114.231.241.108:808 +119.5.217.120:808 +27.222.106.22:80 +59.62.121.30:808 +110.73.32.46:8123 +113.69.254.160:808 +171.38.200.188:8123 +171.38.67.136:8123 +36.249.26.158:808 +171.38.27.217:8123 +218.64.93.204:808 +175.155.241.20:808 +113.69.38.127:808 +119.5.1.6:808 +115.220.144.219:808 +119.7.217.146:808 +120.34.35.222:8998 +120.83.121.41:808 +123.169.88.6:808 +115.202.167.160:808 +220.160.10.59:808 +175.155.247.214:808 +125.106.224.62:808 +120.84.100.185:808 +113.69.252.255:808 +59.62.110.66:808 +110.73.30.204:8123 +123.55.186.73:808 +180.110.17.50:808 +113.122.10.253:808 +113.69.63.156:808 +180.119.65.217:3128 +113.69.63.56:808 +123.55.184.107:808 +112.194.165.166:808 +183.153.14.223:808 +182.121.22.52:8118 +182.42.36.116:808 +183.153.10.177:808 +119.7.81.69:808 +221.229.45.233:808 +114.230.97.1:31983 +112.194.171.231:808 +119.29.24.135:808 +119.7.77.215:808 +119.7.79.174:808 +119.7.79.175:808 +115.213.205.254:808 +113.69.38.216:808 +123.120.121.118:8118 +113.58.235.228:808 +60.167.20.47:808 +119.5.0.108:808 +1.197.58.184:808 +120.83.121.104:808 +218.64.93.156:808 +112.194.217.76:808 +125.120.221.50:808 +115.220.1.12:808 +153.36.39.126:808 +27.18.100.143:808 +113.69.255.41:808 +180.118.240.204:808 +180.110.133.31:808 +14.109.120.73:808 diff --git a/12306login/haha.py b/12306login/haha.py index 4bf21f9..a6acd68 100644 --- a/12306login/haha.py +++ b/12306login/haha.py @@ -44,4 +44,6 @@ import random # 1495457315834 # 428889054675 # 318250603668 -print random.randint(1, 9) +# print random.randint(1, 9) +a = "密码输入错误" +print a.find("121") \ No newline at end of file diff --git a/12306login/init/login.py b/12306login/init/login.py index 29f0bc5..eeb3884 100644 --- a/12306login/init/login.py +++ b/12306login/init/login.py @@ -9,16 +9,6 @@ from damatuCode.damatuWeb import DamatuApi from myUrllib import myurllib2 codeimg = 'https://kyfw.12306.cn/otn/passcodeNew/getPassCodeNew?module=login&rand=sjrand&%s' % random.random() -# 931128603@qq.com -baner = """ -################################## - 12306登录脚本,作者Mr RJL - python版本:2.7,适用于linux - 验证码输入方式: - 输入问题对应的图片序号,1-8; - 多个以','分隔.如:1,2,3 -################################## -""" def cookietp(): @@ -106,41 +96,62 @@ def errorinput(text): def login(user, passwd): - randurl = 'https://kyfw.12306.cn/otn/passcodeNew/checkRandCodeAnsyn' - logurl = 'https://kyfw.12306.cn/otn/login/loginAysnSuggest' - surl = 'https://kyfw.12306.cn/otn/login/userLogin' - geturl = 'https://kyfw.12306.cn/otn/index/initMy12306' - randdata = { - "randCode": randCode, - "rand": "sjrand" - } - logdata = { - "loginUserDTO.user_name": user, - "userDTO.password": passwd, - "randCode": randCode - } - ldata = { - "_json_att": None - } - fresult = json.loads(myurllib2.Post(randurl, randdata), encoding='utf8') - checkcode = fresult['data']['msg'] - if checkcode == 'FALSE': - errorinput("验证码有误,第%s次尝试重试" ) - else: - stoidinput("验证码通过,开始登录..") + """ + 登陆 + :param user: 账户名 + :param passwd: 密码 + :return: + """ + login_num = 0 + while True: + cookietp() + readImg() + login_num += 1 + randurl = 'https://kyfw.12306.cn/otn/passcodeNew/checkRandCodeAnsyn' + logurl = 'https://kyfw.12306.cn/otn/login/loginAysnSuggest' + surl = 'https://kyfw.12306.cn/otn/login/userLogin' + randdata = { + "randCode": randCode, + "rand": "sjrand" + } + logdata = { + "loginUserDTO.user_name": user, + "userDTO.password": passwd, + "randCode": randCode + } + ldata = { + "_json_att": None + } + fresult = json.loads(myurllib2.Post(randurl, randdata), encoding='utf8') + checkcode = fresult['data']['msg'] + if checkcode == 'FALSE': + errorinput("验证码有误,第%s次尝试重试".format(login_num)) + else: + stoidinput("验证码通过,开始登录..") + sleep(1) + try: + tresult = json.loads(myurllib2.Post(logurl, logdata), encoding='utf8') + if 'data' not in tresult: + errorinput("登录失败: %s" % tresult['messages'][0]) + # elif "messages" in tresult and tresult["messages"][0].find("密码输入错误") is not -1: + # errorinput("登陆失败:{}".format(tresult["messages"][0])) + # break + elif 'messages' in tresult and tresult['messages']: + messages = tresult['messages'][0] + if messages.find("密码输入错误") is not -1: + errorinput("登陆失败:{}".format(tresult["messages"][0])) + break + else: + errorinput("登录失败: %s" % tresult['messages'][0]) + stoidinput("尝试重新登陆") + else: + stoidinput("登录成功") + myurllib2.Post(surl, ldata) + getUserinfo() + break + except ValueError as e: + errorinput(e) sleep(1) - try: - tresult = json.loads(myurllib2.Post(logurl, logdata), encoding='utf8') - if 'data' not in tresult: - errorinput("登录失败: %s" % tresult['messages'][0]) - elif 'messages' in tresult and tresult['messages']: - errorinput("登录失败: %s" % tresult['messages']) - else: - stoidinput("登录成功") - myurllib2.Post(surl, ldata) - getUserinfo() - except ValueError as e: - errorinput(e) def getUserinfo(): @@ -160,8 +171,6 @@ def getUserinfo(): def main(): - cookietp() - readImg() login('931128603@qq.com', 'QWERTY') @@ -175,6 +184,5 @@ def logout(): if __name__ == "__main__": - print baner main() # logout() \ No newline at end of file diff --git a/12306login/init/login.pyc b/12306login/init/login.pyc index 9c8898d..482ed4d 100644 Binary files a/12306login/init/login.pyc and b/12306login/init/login.pyc differ diff --git a/12306login/init/select_ticket_info.py b/12306login/init/select_ticket_info.py index 1e6bd76..c900ff9 100644 --- a/12306login/init/select_ticket_info.py +++ b/12306login/init/select_ticket_info.py @@ -116,7 +116,7 @@ class select: if 'data' in jsonData and 'exMsg' in jsonData['data'] and jsonData['data']['exMsg']: print(jsonData['data']['exMsg']) elif 'messages' in jsonData and jsonData['messages']: - print(jsonData['messages']) + print(jsonData['messages'][0]) else: print("未查找到常用联系人") @@ -168,10 +168,11 @@ class select: else: print ('出票失败') elif 'messages' in submitResult and submitResult['messages']: - print(submitResult['messages']) + print(submitResult['messages'][0]) + break else: if check_user['messages']: - print ('用户检查失败:%s' % check_user['messages']) + print ('用户检查失败:%s' % check_user['messages'][0]) else: print ('用户检查失败: %s' % check_user) else: @@ -282,10 +283,11 @@ class select: "REPEAT_SUBMIT_TOKEN": self.get_token(), } checkQueueOrderResult = json.loads(myurllib2.Post(checkQueueOrderUrl, data)) - if "status" is checkQueueOrderResult and checkQueueOrderResult["status"]: - c_data = checkQueueOrderResult["data"] if checkQueueOrderResult["data"] in checkQueueOrderResult else {} + if "status" in checkQueueOrderResult and checkQueueOrderResult["status"]: + c_data = checkQueueOrderResult["data"] if "data" in checkQueueOrderResult else {} if 'submitStatus' in c_data and c_data['submitStatus']: print("出票成功!") + self.queryOrderWaitTime() else: if 'errMsg' in c_data and c_data['errMsg']: print("出票失败," + c_data['errMsg'] + "请重新选择。") @@ -295,11 +297,11 @@ class select: elif "messages" in checkQueueOrderResult and checkQueueOrderResult["messages"]: print("提交订单失败,错误信息: "+ checkQueueOrderResult["messages"]) else: - print("未知错误:" + checkQueueOrderResult["validateMessages"]) + print("未知错误:" + str(checkQueueOrderResult["validateMessages"])) def queryOrderWaitTime(self): """ - 排队获取订单等待信息,每隔1秒请求一次,最高请求次数为20次! + 排队获取订单等待信息,每隔5秒请求一次,最高请求次数为20次! :return: """ queryOrderWaitTimeUrl = "https://kyfw.12306.cn/otn/confirmPassenger/queryOrderWaitTime" @@ -315,11 +317,18 @@ class select: print("订票失败!") break queryOrderWaitTimeResult = json.loads(myurllib2.Post(queryOrderWaitTimeUrl, data)) - if "orderId" in queryOrderWaitTimeResult and queryOrderWaitTimeResult["data"]["orderId"] != "null": - print ("恭喜您订票成功,订单号为:" + queryOrderWaitTimeResult["data"]["orderId"] + ", 请立即打开浏览器登录12306,访问‘未完成订单’,在30分钟内完成支付!") + if "status" in queryOrderWaitTimeResult and queryOrderWaitTimeResult["status"]: + if "orderId" in queryOrderWaitTimeResult["data"] and queryOrderWaitTimeResult["data"]["orderId"] != "null": + print ("恭喜您订票成功,订单号为:" + queryOrderWaitTimeResult["data"]["orderId"] + ", 请立即打开浏览器登录12306,访问‘未完成订单’,在30分钟内完成支付!") + break + elif "msg" in queryOrderWaitTimeResult["data"] and queryOrderWaitTimeResult["data"]["msg"]: + print("订单提交失败:" + queryOrderWaitTimeResult["data"]["msg"]) + break + elif "messages" in queryOrderWaitTimeResult and queryOrderWaitTimeResult["messages"]: + print("订单提交失败: " + queryOrderWaitTimeResult["messages"]) break print("订单提交中,请耐心等待") - time.sleep(1000) + time.sleep(5) def main(self): set_type = self.submitOrderRequest() @@ -328,7 +337,6 @@ class select: self.user_info = self.getPassengerDTOs() self.checkOrderInfo() self.getQueueCount() - self.queryOrderWaitTime() if __name__ == '__main__': a = select('上海', '北京') diff --git a/README.md b/README.md index 1c5448c..bbb8b60 100644 --- a/README.md +++ b/README.md @@ -1 +1,6 @@ # 12306 +2017.5.13跟新 +1、增加登陆错误判断(密码错误&ip校验) +2、修改queryOrderWaitTime,校验orderId字段bug,校验msg字段bug,校验messagesbug +3、修改checkQueueOrder 校验 data 字段的列表推导式bug +4、增加代理ip方法,目前已可以过滤有用ip \ No newline at end of file