python小程序设计4s店_Python 写的一个挑车牌小程序(西安)

去年10月份为了选车牌,研究发现的,现在贴出来,祝大家选到自己心仪的车牌:)

# coding=utf-8

import os

import sys

import urllib2

import random

import time

_t = '%d' %time.time()

_r = '%d' %(random.random()*1000)

_fname = 'num_list_%s.txt'

_c1 = {'_t': '%s', '_list': ('L')};

_c2 = {'_t': '%d', '_list': range(1, 2)};

_c3 = {'_t': '%s', '_list': ('X')};

_c4 = {'_t': '%d', '_list': range(0, 10)};

_c5 = {'_t': '%d', '_list': range(0, 10)};

url = 'http://117.36.53.122:9085/zzxh/business/BusinessAction.do?'

url += 'actiontype=xhgzvalidate&timeStamp='+_t+_r+'&hpzl=02&hphm1=A'

url += '&hphm2='+_c1['_t']+'&hphm3='+_c2['_t']+'&hphm4='+_c3['_t']+'&hphm5='+_c4['_t']+'&hphm6='+_c5['_t']

num = _c1['_t']+_c2['_t']+_c3['_t']+_c4['_t']+_c5['_t']

### get remote content

def file_clear(fname):

_f = open(fname, 'w+')

_f.write('Generated by mrasong at '+time.strftime('%Y-%m-%d %H:%M:%S')+'\n')

_f.close()

return

def file_get_contents(url):

try:

_f = urllib2.urlopen(url, timeout=5)

_content = _f.read()

_content = _content.decode('gbk').encode('utf-8')

return _content.strip()+'\n'

except Exception, e:

return e

def file_put_contents(fname, data):

_f = open(fname, 'a');

_f.write(str(data))

_f.close()

return

for _n1 in _c1['_list']:

_file_name = _fname % _n1

file_clear(_file_name)

for _n2 in _c2['_list']:

for _n3 in _c3['_list']:

for _n4 in _c4['_list']:

for _n5 in _c5['_list']:

#url

_u = (url % ( _n1, _n2, _n3, _n4, _n5, ))

#car num

_num = (num % ( _n1, _n2, _n3, _n4, _n5, ))

_content = file_get_contents(_u)

if( _content[0:2]!='00' ):

continue

_content = _num+'\t'+_content[2:]

file_put_contents(_file_name, _content)

print(_num)

#end _c5

#end _c4

#end _c3

#end _c2

#os.system('pause')

#end _c1

附:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值