Skip to content

Instantly share code, notes, and snippets.

@ihipop
Last active June 25, 2018 07:28
Show Gist options
  • Save ihipop/da6d6c86f93b7e24c6a5b786b820ee7c to your computer and use it in GitHub Desktop.
Save ihipop/da6d6c86f93b7e24c6a5b786b820ee7c to your computer and use it in GitHub Desktop.
王卡选号程序
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
# Created on 2016-11-23
# [email protected]
import requests, time, random, json
from pprint import pprint
import logging
class Wangka(object):
base_url = 'http://num.10010.com/NumApp/GoodsDetail/'
proGroupNum = {"10": "87237287", "11": "85236889", "13": "36236594", "17": "17236695", "18": "15237219",
"19": "59237227", "30": "53236868", "31": "34236498", "34": "33236916", "36": "60236866",
"38": "12236361", "50": "27237168", "51": "21236872", "59": "96237567", "70": "47237252",
"71": "40236873", "74": "71237034", "75": "67237076", "76": "85236973", "79": "13238152",
"81": "20236750", "83": "16236897", "84": "13236970", "85": "53237275", "86": "79237759",
"87": "43236612", "88": "82236693", "89": "90242110", "90": "19236614", "91": "19236028",
"97": "49236584"}
province = {
"11": "北京",
"31": "上海",
"51": "广东",
"38": "福建",
"36": "浙江",
"13": "天津",
"91": "辽宁",
"34": "江苏",
"19": "山西",
"89": "新疆",
"70": "青海",
"18": "河北",
"17": "山东",
"50": "海南",
"84": "陕西",
"10": "内蒙古",
"83": "重庆",
"71": "湖北",
"90": "吉林",
"88": "宁夏",
"97": "黑龙江",
"79": "西藏",
"59": "广西",
"74": "湖南",
"81": "四川",
"76": "河南",
"30": "安徽",
"87": "甘肃",
"86": "云南",
"85": "贵州",
"75": "江西",
}
province_dict = {}
city_dict = {}
city = {"10": [{"CITY_CODE": "101", "CITY_NAME": "呼和浩特"}, {"CITY_CODE": "102", "CITY_NAME": "包头"},
{"CITY_CODE": "106", "CITY_NAME": "乌海"}, {"CITY_CODE": "107", "CITY_NAME": "赤峰"},
{"CITY_CODE": "108", "CITY_NAME": "呼伦贝尔"}, {"CITY_CODE": "113", "CITY_NAME": "兴安盟"},
{"CITY_CODE": "109", "CITY_NAME": "通辽"}, {"CITY_CODE": "103", "CITY_NAME": "乌兰察布"},
{"CITY_CODE": "105", "CITY_NAME": "巴彦淖尔"}, {"CITY_CODE": "114", "CITY_NAME": "阿拉善盟"},
{"CITY_CODE": "104", "CITY_NAME": "鄂尔多斯"}, {"CITY_CODE": "111", "CITY_NAME": "锡林郭勒盟"}],
"11": [{"CITY_CODE": "110", "CITY_NAME": "北京"}], "13": [{"CITY_CODE": "130", "CITY_NAME": "天津"}],
"17": [{"CITY_CODE": "170", "CITY_NAME": "济南"}, {"CITY_CODE": "166", "CITY_NAME": "青岛"},
{"CITY_CODE": "150", "CITY_NAME": "淄博"}, {"CITY_CODE": "157", "CITY_NAME": "枣庄"},
{"CITY_CODE": "156", "CITY_NAME": "东营"}, {"CITY_CODE": "161", "CITY_NAME": "烟台"},
{"CITY_CODE": "155", "CITY_NAME": "潍坊"}, {"CITY_CODE": "158", "CITY_NAME": "济宁"},
{"CITY_CODE": "172", "CITY_NAME": "泰安"}, {"CITY_CODE": "152", "CITY_NAME": "威海"},
{"CITY_CODE": "154", "CITY_NAME": "日照"}, {"CITY_CODE": "160", "CITY_NAME": "莱芜"},
{"CITY_CODE": "153", "CITY_NAME": "临沂"}, {"CITY_CODE": "173", "CITY_NAME": "德州"},
{"CITY_CODE": "174", "CITY_NAME": "聊城"}, {"CITY_CODE": "151", "CITY_NAME": "滨州"},
{"CITY_CODE": "159", "CITY_NAME": "菏泽"}],
"18": [{"CITY_CODE": "188", "CITY_NAME": "石家庄"}, {"CITY_CODE": "181", "CITY_NAME": "唐山"},
{"CITY_CODE": "182", "CITY_NAME": "秦皇岛"}, {"CITY_CODE": "186", "CITY_NAME": "邯郸"},
{"CITY_CODE": "185", "CITY_NAME": "邢台"}, {"CITY_CODE": "187", "CITY_NAME": "保定"},
{"CITY_CODE": "184", "CITY_NAME": "张家口"}, {"CITY_CODE": "189", "CITY_NAME": "承德"},
{"CITY_CODE": "183", "CITY_NAME": "廊坊"}, {"CITY_CODE": "180", "CITY_NAME": "沧州"},
{"CITY_CODE": "720", "CITY_NAME": "衡水"}],
"19": [{"CITY_CODE": "190", "CITY_NAME": "太原"}, {"CITY_CODE": "193", "CITY_NAME": "大同"},
{"CITY_CODE": "192", "CITY_NAME": "阳泉"}, {"CITY_CODE": "195", "CITY_NAME": "长治"},
{"CITY_CODE": "194", "CITY_NAME": "晋城"}, {"CITY_CODE": "199", "CITY_NAME": "朔州"},
{"CITY_CODE": "198", "CITY_NAME": "忻州"}, {"CITY_CODE": "191", "CITY_NAME": "晋中"},
{"CITY_CODE": "200", "CITY_NAME": "吕梁"}, {"CITY_CODE": "197", "CITY_NAME": "临汾"},
{"CITY_CODE": "196", "CITY_NAME": "运城"}],
"30": [{"CITY_CODE": "305", "CITY_NAME": "合肥"}, {"CITY_CODE": "302", "CITY_NAME": "安庆"},
{"CITY_CODE": "301", "CITY_NAME": "蚌埠"}, {"CITY_CODE": "318", "CITY_NAME": "亳州"},
{"CITY_CODE": "317", "CITY_NAME": "池州"}, {"CITY_CODE": "312", "CITY_NAME": "滁州"},
{"CITY_CODE": "306", "CITY_NAME": "阜阳"}, {"CITY_CODE": "314", "CITY_NAME": "淮北"},
{"CITY_CODE": "307", "CITY_NAME": "淮南"}, {"CITY_CODE": "316", "CITY_NAME": "黄山"},
{"CITY_CODE": "304", "CITY_NAME": "六安"}, {"CITY_CODE": "300", "CITY_NAME": "马鞍山"},
{"CITY_CODE": "313", "CITY_NAME": "宿州"}, {"CITY_CODE": "308", "CITY_NAME": "铜陵"},
{"CITY_CODE": "303", "CITY_NAME": "芜湖"}, {"CITY_CODE": "311", "CITY_NAME": "宣城"}],
"31": [{"CITY_CODE": "310", "CITY_NAME": "上海"}],
"34": [{"CITY_CODE": "340", "CITY_NAME": "南京"}, {"CITY_CODE": "450", "CITY_NAME": "苏州"},
{"CITY_CODE": "330", "CITY_NAME": "无锡"}, {"CITY_CODE": "440", "CITY_NAME": "常州"},
{"CITY_CODE": "430", "CITY_NAME": "扬州"}, {"CITY_CODE": "343", "CITY_NAME": "镇江"},
{"CITY_CODE": "358", "CITY_NAME": "南通"}, {"CITY_CODE": "350", "CITY_NAME": "徐州"},
{"CITY_CODE": "445", "CITY_NAME": "泰州"}, {"CITY_CODE": "348", "CITY_NAME": "盐城"},
{"CITY_CODE": "354", "CITY_NAME": "淮安"}, {"CITY_CODE": "346", "CITY_NAME": "连云港"},
{"CITY_CODE": "349", "CITY_NAME": "宿迁"}],
"36": [{"CITY_CODE": "360", "CITY_NAME": "杭州"}, {"CITY_CODE": "370", "CITY_NAME": "宁波"},
{"CITY_CODE": "470", "CITY_NAME": "温州"}, {"CITY_CODE": "476", "CITY_NAME": "台州"},
{"CITY_CODE": "367", "CITY_NAME": "金华"}, {"CITY_CODE": "363", "CITY_NAME": "嘉兴"},
{"CITY_CODE": "365", "CITY_NAME": "绍兴"}, {"CITY_CODE": "362", "CITY_NAME": "湖州"},
{"CITY_CODE": "469", "CITY_NAME": "丽水"}, {"CITY_CODE": "468", "CITY_NAME": "衢州"},
{"CITY_CODE": "364", "CITY_NAME": "舟山"}],
"38": [{"CITY_CODE": "380", "CITY_NAME": "福州"}, {"CITY_CODE": "390", "CITY_NAME": "厦门"},
{"CITY_CODE": "480", "CITY_NAME": "泉州"}, {"CITY_CODE": "395", "CITY_NAME": "漳州"},
{"CITY_CODE": "386", "CITY_NAME": "宁德"}, {"CITY_CODE": "385", "CITY_NAME": "莆田"},
{"CITY_CODE": "387", "CITY_NAME": "南平"}, {"CITY_CODE": "389", "CITY_NAME": "三明"},
{"CITY_CODE": "384", "CITY_NAME": "龙岩"}], "50": [{"CITY_CODE": "501", "CITY_NAME": "海口"}],
"51": [{"CITY_CODE": "510", "CITY_NAME": "广州"}, {"CITY_CODE": "540", "CITY_NAME": "深圳"},
{"CITY_CODE": "580", "CITY_NAME": "东莞"}, {"CITY_CODE": "530", "CITY_NAME": "佛山"},
{"CITY_CODE": "558", "CITY_NAME": "韶关"}, {"CITY_CODE": "670", "CITY_NAME": "河源"},
{"CITY_CODE": "528", "CITY_NAME": "梅州"}, {"CITY_CODE": "570", "CITY_NAME": "惠州"},
{"CITY_CODE": "525", "CITY_NAME": "汕尾"}, {"CITY_CODE": "620", "CITY_NAME": "珠海"},
{"CITY_CODE": "556", "CITY_NAME": "中山"}, {"CITY_CODE": "550", "CITY_NAME": "江门"},
{"CITY_CODE": "560", "CITY_NAME": "汕头"}, {"CITY_CODE": "565", "CITY_NAME": "阳江"},
{"CITY_CODE": "520", "CITY_NAME": "湛江"}, {"CITY_CODE": "568", "CITY_NAME": "茂名"},
{"CITY_CODE": "536", "CITY_NAME": "肇庆"}, {"CITY_CODE": "535", "CITY_NAME": "清远"},
{"CITY_CODE": "531", "CITY_NAME": "潮州"}, {"CITY_CODE": "526", "CITY_NAME": "揭阳"},
{"CITY_CODE": "538", "CITY_NAME": "云浮"}],
"59": [{"CITY_CODE": "591", "CITY_NAME": "南宁"}, {"CITY_CODE": "593", "CITY_NAME": "柳州"},
{"CITY_CODE": "592", "CITY_NAME": "桂林"}, {"CITY_CODE": "594", "CITY_NAME": "梧州"},
{"CITY_CODE": "595", "CITY_NAME": "玉林"}, {"CITY_CODE": "596", "CITY_NAME": "百色"},
{"CITY_CODE": "597", "CITY_NAME": "钦州"}, {"CITY_CODE": "598", "CITY_NAME": "河池"},
{"CITY_CODE": "599", "CITY_NAME": "北海"}, {"CITY_CODE": "590", "CITY_NAME": "防城港"},
{"CITY_CODE": "589", "CITY_NAME": "贵港"}, {"CITY_CODE": "588", "CITY_NAME": "贺州"},
{"CITY_CODE": "600", "CITY_NAME": "崇左"}, {"CITY_CODE": "601", "CITY_NAME": "来宾"}],
"70": [{"CITY_CODE": "700", "CITY_NAME": "西宁"}, {"CITY_CODE": "701", "CITY_NAME": "海东"},
{"CITY_CODE": "702", "CITY_NAME": "格尔木"}, {"CITY_CODE": "704", "CITY_NAME": "海西"},
{"CITY_CODE": "706", "CITY_NAME": "海北"}, {"CITY_CODE": "705", "CITY_NAME": "海南"},
{"CITY_CODE": "707", "CITY_NAME": "黄南"}, {"CITY_CODE": "708", "CITY_NAME": "果洛"},
{"CITY_CODE": "709", "CITY_NAME": "玉树"}],
"71": [{"CITY_CODE": "710", "CITY_NAME": "武汉"}, {"CITY_CODE": "711", "CITY_NAME": "宜昌"},
{"CITY_CODE": "712", "CITY_NAME": "荆州"}, {"CITY_CODE": "714", "CITY_NAME": "黄冈"},
{"CITY_CODE": "715", "CITY_NAME": "黄石"}, {"CITY_CODE": "716", "CITY_NAME": "襄阳"},
{"CITY_CODE": "717", "CITY_NAME": "孝感"}, {"CITY_CODE": "718", "CITY_NAME": "鄂州"},
{"CITY_CODE": "719", "CITY_NAME": "咸宁"}, {"CITY_CODE": "721", "CITY_NAME": "十堰"},
{"CITY_CODE": "723", "CITY_NAME": "随州"}, {"CITY_CODE": "724", "CITY_NAME": "荆门"},
{"CITY_CODE": "713", "CITY_NAME": "仙桃"}, {"CITY_CODE": "727", "CITY_NAME": "恩施"}],
"74": [{"CITY_CODE": "741", "CITY_NAME": "长沙"}, {"CITY_CODE": "744", "CITY_NAME": "衡阳"},
{"CITY_CODE": "742", "CITY_NAME": "株洲"}, {"CITY_CODE": "743", "CITY_NAME": "湘潭"},
{"CITY_CODE": "745", "CITY_NAME": "岳阳"}, {"CITY_CODE": "792", "CITY_NAME": "邵阳"},
{"CITY_CODE": "748", "CITY_NAME": "郴州"}, {"CITY_CODE": "749", "CITY_NAME": "常德"},
{"CITY_CODE": "747", "CITY_NAME": "益阳"}, {"CITY_CODE": "795", "CITY_NAME": "怀化"},
{"CITY_CODE": "796", "CITY_NAME": "永州"}, {"CITY_CODE": "791", "CITY_NAME": "娄底"},
{"CITY_CODE": "793", "CITY_NAME": "湘西"}, {"CITY_CODE": "794", "CITY_NAME": "张家界"}],
"75": [{"CITY_CODE": "750", "CITY_NAME": "南昌"}, {"CITY_CODE": "755", "CITY_NAME": "九江"},
{"CITY_CODE": "757", "CITY_NAME": "上饶"}, {"CITY_CODE": "759", "CITY_NAME": "抚州"},
{"CITY_CODE": "756", "CITY_NAME": "宜春"}, {"CITY_CODE": "751", "CITY_NAME": "吉安"},
{"CITY_CODE": "752", "CITY_NAME": "赣州"}, {"CITY_CODE": "740", "CITY_NAME": "景德镇"},
{"CITY_CODE": "758", "CITY_NAME": "萍乡"}, {"CITY_CODE": "753", "CITY_NAME": "新余"},
{"CITY_CODE": "754", "CITY_NAME": "鹰潭"}],
"76": [{"CITY_CODE": "760", "CITY_NAME": "郑州"}, {"CITY_CODE": "761", "CITY_NAME": "洛阳"},
{"CITY_CODE": "762", "CITY_NAME": "开封"}, {"CITY_CODE": "763", "CITY_NAME": "焦作"},
{"CITY_CODE": "764", "CITY_NAME": "新乡"}, {"CITY_CODE": "765", "CITY_NAME": "许昌"},
{"CITY_CODE": "766", "CITY_NAME": "漯河"}, {"CITY_CODE": "767", "CITY_NAME": "安阳"},
{"CITY_CODE": "768", "CITY_NAME": "商丘"}, {"CITY_CODE": "769", "CITY_NAME": "平顶山"},
{"CITY_CODE": "770", "CITY_NAME": "周口"}, {"CITY_CODE": "771", "CITY_NAME": "驻马店"},
{"CITY_CODE": "772", "CITY_NAME": "三门峡"}, {"CITY_CODE": "773", "CITY_NAME": "濮阳"},
{"CITY_CODE": "774", "CITY_NAME": "鹤壁"}, {"CITY_CODE": "775", "CITY_NAME": "济源"},
{"CITY_CODE": "776", "CITY_NAME": "信阳"}, {"CITY_CODE": "777", "CITY_NAME": "南阳"}],
"79": [{"CITY_CODE": "790", "CITY_NAME": "拉萨"}, {"CITY_CODE": "797", "CITY_NAME": "日喀则"},
{"CITY_CODE": "798", "CITY_NAME": "山南"}, {"CITY_CODE": "799", "CITY_NAME": "林芝"},
{"CITY_CODE": "800", "CITY_NAME": "昌都"}, {"CITY_CODE": "801", "CITY_NAME": "那曲"},
{"CITY_CODE": "802", "CITY_NAME": "阿里"}],
"81": [{"CITY_CODE": "810", "CITY_NAME": "成都"}, {"CITY_CODE": "813", "CITY_NAME": "攀枝花"},
{"CITY_CODE": "815", "CITY_NAME": "泸州"}, {"CITY_CODE": "825", "CITY_NAME": "德阳"},
{"CITY_CODE": "824", "CITY_NAME": "绵阳"}, {"CITY_CODE": "826", "CITY_NAME": "广元"},
{"CITY_CODE": "821", "CITY_NAME": "遂宁"}, {"CITY_CODE": "816", "CITY_NAME": "内江"},
{"CITY_CODE": "814", "CITY_NAME": "乐山"}, {"CITY_CODE": "822", "CITY_NAME": "南充"},
{"CITY_CODE": "817", "CITY_NAME": "宜宾"}, {"CITY_CODE": "823", "CITY_NAME": "广安"},
{"CITY_CODE": "820", "CITY_NAME": "达州"}, {"CITY_CODE": "827", "CITY_NAME": "巴中"},
{"CITY_CODE": "811", "CITY_NAME": "雅安"}, {"CITY_CODE": "819", "CITY_NAME": "眉山"},
{"CITY_CODE": "830", "CITY_NAME": "资阳"}, {"CITY_CODE": "829", "CITY_NAME": "阿坝"},
{"CITY_CODE": "828", "CITY_NAME": "甘孜"}, {"CITY_CODE": "812", "CITY_NAME": "凉山"},
{"CITY_CODE": "818", "CITY_NAME": "自贡"}], "83": [{"CITY_CODE": "831", "CITY_NAME": "重庆"}],
"84": [{"CITY_CODE": "841", "CITY_NAME": "西安"}, {"CITY_CODE": "844", "CITY_NAME": "咸阳"},
{"CITY_CODE": "843", "CITY_NAME": "渭南"}, {"CITY_CODE": "840", "CITY_NAME": "宝鸡"},
{"CITY_CODE": "849", "CITY_NAME": "汉中"}, {"CITY_CODE": "842", "CITY_NAME": "延安"},
{"CITY_CODE": "845", "CITY_NAME": "榆林"}, {"CITY_CODE": "846", "CITY_NAME": "铜川"},
{"CITY_CODE": "848", "CITY_NAME": "安康"}, {"CITY_CODE": "847", "CITY_NAME": "商洛"}],
"85": [{"CITY_CODE": "850", "CITY_NAME": "贵阳"}, {"CITY_CODE": "787", "CITY_NAME": "遵义"},
{"CITY_CODE": "789", "CITY_NAME": "安顺"}, {"CITY_CODE": "788", "CITY_NAME": "黔南"},
{"CITY_CODE": "786", "CITY_NAME": "黔东南"}, {"CITY_CODE": "785", "CITY_NAME": "铜仁"},
{"CITY_CODE": "851", "CITY_NAME": "毕节"}, {"CITY_CODE": "853", "CITY_NAME": "六盘水"},
{"CITY_CODE": "852", "CITY_NAME": "黔西南"}],
"86": [{"CITY_CODE": "860", "CITY_NAME": "昆明"}, {"CITY_CODE": "730", "CITY_NAME": "德宏"},
{"CITY_CODE": "731", "CITY_NAME": "保山"}, {"CITY_CODE": "732", "CITY_NAME": "文山"},
{"CITY_CODE": "733", "CITY_NAME": "临沧"}, {"CITY_CODE": "734", "CITY_NAME": "怒江"},
{"CITY_CODE": "735", "CITY_NAME": "迪庆"}, {"CITY_CODE": "736", "CITY_NAME": "西双版纳"},
{"CITY_CODE": "861", "CITY_NAME": "红河"}, {"CITY_CODE": "862", "CITY_NAME": "大理"},
{"CITY_CODE": "863", "CITY_NAME": "丽江"}, {"CITY_CODE": "864", "CITY_NAME": "楚雄"},
{"CITY_CODE": "865", "CITY_NAME": "玉溪"}, {"CITY_CODE": "866", "CITY_NAME": "曲靖"},
{"CITY_CODE": "867", "CITY_NAME": "昭通"}, {"CITY_CODE": "869", "CITY_NAME": "普洱"}],
"87": [{"CITY_CODE": "870", "CITY_NAME": "兰州"}, {"CITY_CODE": "931", "CITY_NAME": "酒泉"},
{"CITY_CODE": "873", "CITY_NAME": "庆阳"}, {"CITY_CODE": "877", "CITY_NAME": "天水"},
{"CITY_CODE": "874", "CITY_NAME": "武威"}, {"CITY_CODE": "878", "CITY_NAME": "临夏"},
{"CITY_CODE": "879", "CITY_NAME": "白银"}, {"CITY_CODE": "871", "CITY_NAME": "定西"},
{"CITY_CODE": "872", "CITY_NAME": "平凉"}, {"CITY_CODE": "960", "CITY_NAME": "陇南"},
{"CITY_CODE": "875", "CITY_NAME": "张掖"}, {"CITY_CODE": "876", "CITY_NAME": "嘉峪关"},
{"CITY_CODE": "930", "CITY_NAME": "金昌"}, {"CITY_CODE": "961", "CITY_NAME": "甘南"}],
"88": [{"CITY_CODE": "880", "CITY_NAME": "银川"}, {"CITY_CODE": "884", "CITY_NAME": "石嘴山"},
{"CITY_CODE": "883", "CITY_NAME": "吴忠"}, {"CITY_CODE": "885", "CITY_NAME": "固原"},
{"CITY_CODE": "886", "CITY_NAME": "中卫"}],
"89": [{"CITY_CODE": "890", "CITY_NAME": "乌鲁木齐"}, {"CITY_CODE": "891", "CITY_NAME": "昌吉"},
{"CITY_CODE": "893", "CITY_NAME": "石河子"}, {"CITY_CODE": "892", "CITY_NAME": "奎屯"},
{"CITY_CODE": "952", "CITY_NAME": "塔城"}, {"CITY_CODE": "899", "CITY_NAME": "克拉玛依"},
{"CITY_CODE": "898", "CITY_NAME": "伊犁"}, {"CITY_CODE": "951", "CITY_NAME": "博乐"},
{"CITY_CODE": "953", "CITY_NAME": "阿勒泰"}, {"CITY_CODE": "894", "CITY_NAME": "吐鲁番"},
{"CITY_CODE": "900", "CITY_NAME": "哈密"}, {"CITY_CODE": "895", "CITY_NAME": "巴音郭楞"},
{"CITY_CODE": "896", "CITY_NAME": "阿克苏"}, {"CITY_CODE": "897", "CITY_NAME": "喀什"},
{"CITY_CODE": "955", "CITY_NAME": "和田"}, {"CITY_CODE": "954", "CITY_NAME": "克孜勒苏"}],
"90": [{"CITY_CODE": "901", "CITY_NAME": "长春"}, {"CITY_CODE": "902", "CITY_NAME": "吉林"},
{"CITY_CODE": "909", "CITY_NAME": "延边"}, {"CITY_CODE": "903", "CITY_NAME": "四平"},
{"CITY_CODE": "905", "CITY_NAME": "通化"}, {"CITY_CODE": "907", "CITY_NAME": "白城"},
{"CITY_CODE": "906", "CITY_NAME": "辽源"}, {"CITY_CODE": "904", "CITY_NAME": "松原"},
{"CITY_CODE": "908", "CITY_NAME": "白山"}],
"91": [{"CITY_CODE": "910", "CITY_NAME": "沈阳"}, {"CITY_CODE": "940", "CITY_NAME": "大连"},
{"CITY_CODE": "912", "CITY_NAME": "鞍山"}, {"CITY_CODE": "913", "CITY_NAME": "抚顺"},
{"CITY_CODE": "914", "CITY_NAME": "本溪"}, {"CITY_CODE": "915", "CITY_NAME": "丹东"},
{"CITY_CODE": "916", "CITY_NAME": "锦州"}, {"CITY_CODE": "917", "CITY_NAME": "营口"},
{"CITY_CODE": "918", "CITY_NAME": "阜新"}, {"CITY_CODE": "919", "CITY_NAME": "辽阳"},
{"CITY_CODE": "911", "CITY_NAME": "铁岭"}, {"CITY_CODE": "920", "CITY_NAME": "朝阳"},
{"CITY_CODE": "921", "CITY_NAME": "盘锦"}, {"CITY_CODE": "922", "CITY_NAME": "葫芦岛"}],
"97": [{"CITY_CODE": "971", "CITY_NAME": "哈尔滨"}, {"CITY_CODE": "973", "CITY_NAME": "齐齐哈尔"},
{"CITY_CODE": "988", "CITY_NAME": "牡丹江"}, {"CITY_CODE": "976", "CITY_NAME": "佳木斯"},
{"CITY_CODE": "989", "CITY_NAME": "绥化"}, {"CITY_CODE": "981", "CITY_NAME": "大庆"},
{"CITY_CODE": "991", "CITY_NAME": "鸡西"}, {"CITY_CODE": "990", "CITY_NAME": "黑河"},
{"CITY_CODE": "996", "CITY_NAME": "伊春"}, {"CITY_CODE": "994", "CITY_NAME": "双鸭山"},
{"CITY_CODE": "993", "CITY_NAME": "鹤岗"}, {"CITY_CODE": "992", "CITY_NAME": "七台河"},
{"CITY_CODE": "995", "CITY_NAME": "大兴安岭"}]}
crawl_config = {
"headers": {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.134 Safari/537.36',
# "Connection":"keep-alive",
# "Content-Length":"67",
"Pragma": "no-cache",
"Cache-Control": "no-cache",
"Accept": "*/*",
"Origin:http": "//m.10010.com",
"X-Requested-With": "XMLHttpRequest",
"User-Agent": "Mozilla/5.0 (Linux; Android 5.1.1; Redmi Note 3 Build/LMY47V) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/37.0.0.0 Mobile MQQBrowser/6.8 TBS/036884 Safari/537.36 QQLiveBrowser/5.1.2.11019",
# "Content-Type":"application/x-www-form-urlencoded",
"Referer:http": "//m.10010.com/mall-mobile/kingNumCard/init?tencentId=EABE34A72B9B0B71ABD5F15B6961CF78EFAE5851D0F83947B9F8B8AF&key=7FB67E24E91B8527BEBD2EB97D8DDFAFB0612E1C151892D06E83339C3A6D7F88&product=4&channel=2",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4",
},
# replace (\w+)\=(.*?)(\; |$)
# with "\1":"\2", \n
"cookies": {
# IP定位城市
"gipgeo": "36|360",
# "WT_FPC":"id=2655b55b25d6a70ab651479816610317:lv=1479816610324:ss=1479816610317",
# "MUT_V":"null",
# "u_mobilePhone":"",
# "u_psptId":"",
# "TC_JQ_CD":"q3d5tnQolV/UVGL74E4oUw==",
# "_n3fa_cid":"30a908367fcd4611d03ccf5c18b25dfb",
# "_n3fa_ext":"ft=1479173745",
# "_n3fa_lvt_a9e72dfe4a54a20c3d6e671b3bad01d9":"1479816610,1479869104,1479870452,1479871023",
# "_n3fa_lpvt_a9e72dfe4a54a20c3d6e671b3bad01d9":"1479871023",
# 预订号码使用的UUID,预先占用的号码会被绑定到这个UUID上
"MUT": "3cf70215-6913-4d12-bd31-8412c86a7d47",
# 不知道干嘛用 干脆就保持一致吧
"MUT_KZRW": "3cf70215-6913-4d12-bd31-8412c86a7d47",
# 游客
"USER_NAME": "%E8%AE%BF%E5%AE%A2",
# Cookies定位城市
"mallcity": "34|330",
# "SHOP_PROV_CITY":"",
}
}
WANGKA_GOODS_ID = 341610241533
# 音乐小王卡 product=3
# 视频小王 product=4
WANGKA_MUSCI = 3
WANGKA_VIDEO = 4
logger = logging.getLogger()
def __init__(self):
pass
def get_province_city_code(self, province, city):
if not self.province_dict:
self.province_dict = dict((v, k) for k, v in self.province.items())
if not self.city_dict:
for p, list in self.city.items():
cs = {}
for c in list:
cs.update({c['CITY_NAME']: c['CITY_CODE']})
self.city_dict.update({p: cs})
province = obj.province_dict[province]
city = self.city_dict[province][city]
# pprint(self.province_dict)
# pprint(self.city_dict)
return {
'province': province,
'city': city
}
def get_online_nums(self, province, city, wait=False):
# ts = int(time.time()*1000)
# int = random.randint(171046537703500000000,171046537703599999999)
url = self.base_url + 'queryNums4Mobile'
groupKey = self.proGroupNum[province]
def build_query():
query = {
"callback": "jQuery{int}_{ts}".format(int=random.randint(171046537703500000000, 171046537703599999999),
ts=int(time.time() * 1000)),
"cityCode": city, # 330 无锡市
"keyValue": "",
"net": "01",
"preFeeSel": "0",
"province": province, # 34 江苏省
"groupKey": groupKey, # 江苏省 33236916
"roleValue": "",
"showShareNum": "false",
"Show4GNum": "FALSE",
"goodsNet": 4,
"q_p": random.randint(1, 9),
"_": int(time.time() * 1000),
}
return query
result = []
lenResult = len(result)
pprint(url)
maxWait = 10
while maxWait > 0:
query = build_query()
# pprint(query)
try:
r = requests.get(url, params=query, headers=self.crawl_config['headers'],
cookies=self.crawl_config['cookies'])
r = (''.join(r.text.split('(')[1:]).rstrip(';').rstrip(')'))
r = json.loads(r)['moreNumArray']
r = [x for x in r if len(str(x)) == 11]
except Exception as e:
r = []
result.extend(r)
result = list(set(result))
pprint('Got %s num,Result Size %s, new %s' % (len(r), len(result), len(result) - lenResult))
if not wait:
break
if len(result) == lenResult:
maxWait -= 1
else:
maxWait = 10
# pprint(maxWait)
lenResult = len(result)
result.sort()
# pprint(result)
return result
def occupy_num(self, numID, goodsId, provinceCode=None, cityCode=None):
url = 'http://m.10010.com/mall-mobile/PromptlyBuyNumAjax/occupyNumberAjax'
payload = {
"provinceCode": provinceCode, # 34 江苏省
"cityCode": cityCode, # 330 无锡市
"numID": numID,
"goodsId": goodsId
}
r = requests.post(url, data=payload, headers=self.crawl_config['headers'], cookies=self.crawl_config['cookies'])
errorCodes = {
'R0002': '空号',
'R9999': '被占用不可选'
}
text = r.text.strip(' "')
for errorCode, msg in errorCodes.items():
if errorCode in r.text:
return [errorCode, msg, text.split('FrontInput')[1:]]
if 'FrontInput' in text:
return ['R0000', text.split('FrontInput')[1:]]
return [0, text]
if __name__ == '__main__':
obj = Wangka()
# result = obj.get_online_nums(wait=True)
'''
测试号码 释放后如果大约半小时内不能成交,号码被收回
17605109412 3cf70215-6913-4d12-bd31-8412c86a7d47
17605109680 未知占用
'''
cityStr = '江苏-无锡'
provinceCN = cityStr.split('-')[0]
cityCN = cityStr.split('-')[1]
cityCode = obj.get_province_city_code(provinceCN, cityCN)
# pprint(obj.occupy_num('17605100000',obj.WANGKA_GOODS_ID,provinceCode=cityCode['province'],cityCode=cityCode['city']))
with open(cityStr + '.txt', 'w+') as numDataFile:
nums = obj.get_online_nums(cityCode['province'], cityCode['city'], wait=True)
for num in nums:
numDataFile.write(str(num) + '\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment