Last active
February 2, 2016 09:47
-
-
Save ihipop/1e8b73aa96659af2470c to your computer and use it in GitHub Desktop.
中国电信在线选号测试
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#=====================Config====================== | |
mainLog=phone.log | |
filterLog=phone.filter.log | |
maxTries=100 | |
#=====================Config====================== | |
function fetch { | |
curl -Ss --request GET \ | |
--url 'http://js.189.cn/nmall/shop/number/queryNumber.json?areaId=16&areaCode=0510&numberHead=&showCount=50&isFour=&matchNum=&numberFee=-1&numberFlag=1' \ | |
--header 'accept: application/json, text/javascript, */*; q=0.01' \ | |
--header 'cache-control: no-cache' \ | |
--header 'referer: http//js.189.cn/nmall/purchase/package?fnumber=SXP20150623000922' \ | |
--header 'user-agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36' \ | |
--header 'x-requested-with: XMLHttpRequest' | |
} | |
>${mainLog} | |
while true; do | |
fetch >>${mainLog} ; | |
echo >>${mainLog} ; | |
s=$(grep -oP '"accNbr":"\d{11}' ${mainLog}|grep -oP "\d{11}"|sort|uniq); | |
sn=`echo "$s" |wc -l`; | |
if [[ "$sln" == "$sn" ]];then | |
counter=$(($counter + 1)); | |
[[ "$counter" -ge $maxTries ]] && echo finish after repeter $counter && break; | |
else | |
echo reset counter to zero | |
counter=0; | |
fi | |
sln=$sn; | |
echo -n "got $sn num "; | |
sleep 1; | |
echo getting next data; | |
done | |
echo writing filter file $filterLog | |
echo "$s" > $filterLog |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment