Bug Fixed: Retry times limited to 3
Due to some reason, some data is possibly not able to be fetched. If there's not a limitation, the system will retry until it succeed.
This commit is contained in:
parent
b1170f6d36
commit
48056daea9
22
main.cpp
22
main.cpp
@ -50,7 +50,7 @@ double LocalParse(int id)
|
|||||||
|
|
||||||
void prepareCookie()
|
void prepareCookie()
|
||||||
{
|
{
|
||||||
system(R"(curl -v "life.ccb.com/tran/WCCMainPlatV5?CCB_IBSVersion=V5&SERVLET_NAME=WCCMainPlatV5&TXCODE=100119&USERID=&SKEY=" --user-agent "Mozilla/5.0 (Windows NT 6.1; rv:14.0) Gecko/20100101 Firefox/14.0.1" -c temp/cookie1.txt > temp/step1.txt)");
|
system(R"(curl -s "life.ccb.com/tran/WCCMainPlatV5?CCB_IBSVersion=V5&SERVLET_NAME=WCCMainPlatV5&TXCODE=100119&USERID=&SKEY=" --user-agent "Mozilla/5.0 (Windows NT 6.1; rv:14.0) Gecko/20100101 Firefox/14.0.1" -c temp/cookie1.txt > temp/step1.txt)");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _fetched_cookie=false;
|
bool _fetched_cookie=false;
|
||||||
@ -66,7 +66,7 @@ void BeginNetwork()
|
|||||||
|
|
||||||
void RunCommand(string stuNumber,string outputFilename)
|
void RunCommand(string stuNumber,string outputFilename)
|
||||||
{
|
{
|
||||||
string cmd=R"(curl -v "life.ccb.com/tran/WCCMainPlatV5?CCB_IBSVersion=V5&SERVLET_NAME=WCCMainPlatV5&isAjaxRequest=true&TXCODE=JF1103&OPUN_COD=370200&MERCHANT=#STUCODE#100010&COMM=#STUCODE#&BANK_COD=370000&BIll_CODE=100010&PAY_TYPE=11&BILL_FLAG=0&BIll_MERCHANT=600007&BANK_NAME=%E5%B1%B1%E4%B8%9C%E7%9C%81&OPUN_NAME=%E9%9D%92%E5%B2%9B%E5%B8%82&MERCHANT_NAME=%E9%9D%92%E5%B2%9B%E7%A7%91%E6%8A%80%E5%A4%A7%E5%AD%A6%E6%A0%A1%E5%9B%AD%E5%8D%A1%E5%85%85%E5%80%BC&BILL_TYPE=2&BRAN_NO=371000000&BILL_ITEM=01013&BILL_NAME=IC%E5%8D%A1%E3%80%81%E8%81%94%E5%90%8D%E5%8D%A1%E5%85%85%E5%80%BC&RE1CON=&RE2CON=" --user-agent "Mozilla/5.0 (Windows NT 6.1; rv:14.0) Gecko/20100101 Firefox/14.0.1" -b "temp/cookie1.txt" > )" ;
|
string cmd=R"(curl -s "life.ccb.com/tran/WCCMainPlatV5?CCB_IBSVersion=V5&SERVLET_NAME=WCCMainPlatV5&isAjaxRequest=true&TXCODE=JF1103&OPUN_COD=370200&MERCHANT=#STUCODE#100010&COMM=#STUCODE#&BANK_COD=370000&BIll_CODE=100010&PAY_TYPE=11&BILL_FLAG=0&BIll_MERCHANT=600007&BANK_NAME=%E5%B1%B1%E4%B8%9C%E7%9C%81&OPUN_NAME=%E9%9D%92%E5%B2%9B%E5%B8%82&MERCHANT_NAME=%E9%9D%92%E5%B2%9B%E7%A7%91%E6%8A%80%E5%A4%A7%E5%AD%A6%E6%A0%A1%E5%9B%AD%E5%8D%A1%E5%85%85%E5%80%BC&BILL_TYPE=2&BRAN_NO=371000000&BILL_ITEM=01013&BILL_NAME=IC%E5%8D%A1%E3%80%81%E8%81%94%E5%90%8D%E5%8D%A1%E5%85%85%E5%80%BC&RE1CON=&RE2CON=" --user-agent "Mozilla/5.0 (Windows NT 6.1; rv:14.0) Gecko/20100101 Firefox/14.0.1" -b "temp/cookie1.txt" > )" ;
|
||||||
|
|
||||||
string target="#STUCODE#";
|
string target="#STUCODE#";
|
||||||
|
|
||||||
@ -91,8 +91,8 @@ void RemoteQuery(string PreCode,int ID)
|
|||||||
printf("执行查询.. StuID=%s\n",stuCode.c_str());
|
printf("执行查询.. StuID=%s\n",stuCode.c_str());
|
||||||
RunCommand(stuCode,Filename);
|
RunCommand(stuCode,Filename);
|
||||||
|
|
||||||
/// Delay 3~6 seconds
|
/// Delay 1~4 seconds
|
||||||
this_thread::sleep_for(chrono::seconds(rand()%3+3));
|
this_thread::sleep_for(chrono::seconds(rand()%3+1));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define HEAD_STR "15080901"
|
#define HEAD_STR "15080901"
|
||||||
@ -118,7 +118,7 @@ int main()
|
|||||||
|
|
||||||
printf("查询完成,开始解析...\n");
|
printf("查询完成,开始解析...\n");
|
||||||
vector<double> vec;
|
vector<double> vec;
|
||||||
queue<int> needrefetch;
|
queue<pair<int,int>> needrefetch;
|
||||||
|
|
||||||
for(int i=0;i<NUM;i++)
|
for(int i=0;i<NUM;i++)
|
||||||
{
|
{
|
||||||
@ -126,7 +126,7 @@ int main()
|
|||||||
double val=LocalParse(i+1);
|
double val=LocalParse(i+1);
|
||||||
if(val==-2)
|
if(val==-2)
|
||||||
{
|
{
|
||||||
needrefetch.push(i+1);
|
needrefetch.push(make_pair(i+1,0));
|
||||||
}
|
}
|
||||||
vec.push_back(val);
|
vec.push_back(val);
|
||||||
}
|
}
|
||||||
@ -142,15 +142,21 @@ int main()
|
|||||||
BeginNetwork();
|
BeginNetwork();
|
||||||
while(!needrefetch.empty())
|
while(!needrefetch.empty())
|
||||||
{
|
{
|
||||||
int id=needrefetch.front();
|
pair<int,int> pack=needrefetch.front();
|
||||||
needrefetch.pop();
|
needrefetch.pop();
|
||||||
|
int id=pack.first;
|
||||||
printf("重新获取ID: %d\n",id);
|
printf("重新获取ID: %d\n",id);
|
||||||
RemoteQuery(HEAD_STR,id);
|
RemoteQuery(HEAD_STR,id);
|
||||||
double val=LocalParse(id);
|
double val=LocalParse(id);
|
||||||
if(val==-2)
|
if(val==-2)
|
||||||
{
|
{
|
||||||
printf("重新获取ID: %d 失败.\n",id);
|
printf("重新获取ID: %d 失败.\n",id);
|
||||||
needrefetch.push(id);
|
|
||||||
|
if(pack.second<3)
|
||||||
|
{
|
||||||
|
printf("重新获取失败多次,停止获取ID: %d.\n",id);
|
||||||
|
needrefetch.push(make_pair(id,pack.second+1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user