Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
ikylin committed Dec 26, 2012
1 parent e963201 commit 37fc1b3
Show file tree
Hide file tree
Showing 8 changed files with 2,221 additions and 10,914 deletions.
10,500 changes: 0 additions & 10,500 deletions common.tools/id.txt

This file was deleted.

183 changes: 112 additions & 71 deletions common.tools/src/main/java/uims/common/tools/app/KDGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@
import org.apache.http.protocol.HttpContext;
import org.apache.log4j.Logger;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

import uims.common.tools.util.BasicMultiThreadedHttpClient;

public class KDGen extends BasicMultiThreadedHttpClient {

static Logger log = Logger.getLogger(KDGen.class.getName());

static String num = "243489559219";
static String num = "243490331503";
private static String id;

// create context
Expand All @@ -43,104 +44,144 @@ public static void main(String[] args) {
private void action() {
// queryIds();

// genIds();


setLocalCookieManger();

queryInit();
queryIds20();

genIds();

shutdown();
}

private void queryIds20() {

private int queryIds20(String idList) {

int idOkNum = 0;
String imgUrl = "http://kf.sf-express.com/css/loginmgmt/imgcode?flag=1";
// __utma Sent 265537869.174798303.1356352082.1356352082.1356352082.1 / .sf-express.com Wed, 24 Dec 2014 12:28:01 UTC JavaScript No No
// __utmb Sent 265537869.1.10.1356352082 / .sf-express.com Mon, 24 Dec 2012 12:58:01 UTC JavaScript No No
// __utmc Sent 265537869 / .sf-express.com (Session) JavaScript No No
// __utmz Sent 265537869.1356352082.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none) / .sf-express.com Tue, 25 Jun 2013 00:28:01 UTC JavaScript No No
// JSESSIONID Sent 6B6270A4A50F525A47CA1967D4B98CC7 / .kf.sf-express.com (Session) Server No No
// locale Sent zh_CN / .kf.sf-express.com Tue, 25-Dec-2012 05:08:08 GMT Server No No
// SERVERID Sent css9 / .kf.sf-express.com (Session) Server No No
// __utma Sent 265537869.174798303.1356352082.1356352082.1356352082.1 /
// .sf-express.com Wed, 24 Dec 2014 12:28:01 UTC JavaScript No No
// __utmb Sent 265537869.1.10.1356352082 / .sf-express.com Mon, 24 Dec
// 2012 12:58:01 UTC JavaScript No No
// __utmc Sent 265537869 / .sf-express.com (Session) JavaScript No No
// __utmz Sent
// 265537869.1356352082.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
// / .sf-express.com Tue, 25 Jun 2013 00:28:01 UTC JavaScript No No
// JSESSIONID Sent 6B6270A4A50F525A47CA1967D4B98CC7 / .kf.sf-express.com
// (Session) Server No No
// locale Sent zh_CN / .kf.sf-express.com Tue, 25-Dec-2012 05:08:08 GMT
// Server No No
// SERVERID Sent css9 / .kf.sf-express.com (Session) Server No No
String checkNum = getChkImageOCR(imgUrl, "1");


String queryUrl = "http://kf.sf-express.com/css/myquery/queryWQSBill.action?waybills=" +
"243489559228%0D%0A243489559237%0D%0A243489559246%0D%0A243489559255%0D%0A243489559264%0D%0A243489559273%0D%0A243489559282%0D%0A243489559291%0D%0A243489559307%0D%0A243489559316%0D%0A243489559325%0D%0A243489559334%0D%0A243489559343%0D%0A243489559352%0D%0A243489559361%0D%0A243489559370%0D%0A243489559389%0D%0A243489559398%0D%0A243489559403%0D%0A243489559412" +
"&verifycode=" +
checkNum +//"6wz6" +

String queryUrl = "http://kf.sf-express.com/css/myquery/queryWQSBill.action?waybills="
+ idList + // "243489559228%0D%0A243489559237%0D%0A243489559246%0D%0A243489559255%0D%0A243489559264%0D%0A243489559273%0D%0A243489559282%0D%0A243489559291%0D%0A243489559307%0D%0A243489559316%0D%0A243489559325%0D%0A243489559334%0D%0A243489559343%0D%0A243489559352%0D%0A243489559361%0D%0A243489559370%0D%0A243489559389%0D%0A243489559398%0D%0A243489559403%0D%0A243489559412"
// +
"&verifycode=" + checkNum + // "6wz6" +
"";
// verifycode 6wz6
// waybills 243489559228
// 243489559237
// 243489559246
// 243489559255
// 243489559264
// 243489559273
// 243489559282
// 243489559291
// 243489559307
// 243489559316
// 243489559325
// 243489559334
// 243489559343
// 243489559352
// 243489559361
// 243489559370
// 243489559389
// 243489559398
// 243489559403
// 243489559412

// __utma Sent 265537869.174798303.1356352082.1356352082.1356352082.1 / .sf-express.com Wed, 24 Dec 2014 12:28:01 UTC JavaScript No No
// __utmb Sent 265537869.1.10.1356352082 / .sf-express.com Mon, 24 Dec 2012 12:58:01 UTC JavaScript No No
// __utmc Sent 265537869 / .sf-express.com (Session) JavaScript No No
// __utmz Sent 265537869.1356352082.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none) / .sf-express.com Tue, 25 Jun 2013 00:28:01 UTC JavaScript No No
// JSESSIONID Sent 6B6270A4A50F525A47CA1967D4B98CC7 / .kf.sf-express.com (Session) Server No No
// locale Sent zh_CN / .kf.sf-express.com Tue, 25-Dec-2012 05:08:08 GMT Server No No
// SERVERID Sent css9 / .kf.sf-express.com (Session) Server No No

// verifycode 6wz6
// waybills 243489559228
// 243489559237
// 243489559246
// 243489559255
// 243489559264
// 243489559273
// 243489559282
// 243489559291
// 243489559307
// 243489559316
// 243489559325
// 243489559334
// 243489559343
// 243489559352
// 243489559361
// 243489559370
// 243489559389
// 243489559398
// 243489559403
// 243489559412

// __utma Sent 265537869.174798303.1356352082.1356352082.1356352082.1 /
// .sf-express.com Wed, 24 Dec 2014 12:28:01 UTC JavaScript No No
// __utmb Sent 265537869.1.10.1356352082 / .sf-express.com Mon, 24 Dec
// 2012 12:58:01 UTC JavaScript No No
// __utmc Sent 265537869 / .sf-express.com (Session) JavaScript No No
// __utmz Sent
// 265537869.1356352082.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
// / .sf-express.com Tue, 25 Jun 2013 00:28:01 UTC JavaScript No No
// JSESSIONID Sent 6B6270A4A50F525A47CA1967D4B98CC7 / .kf.sf-express.com
// (Session) Server No No
// locale Sent zh_CN / .kf.sf-express.com Tue, 25-Dec-2012 05:08:08 GMT
// Server No No
// SERVERID Sent css9 / .kf.sf-express.com (Session) Server No No

Document doc = getText(queryUrl);
doc.select("table");
Elements lines = doc
.select("table>tbody>tr:eq(1)>td:eq(1)>table>tbody>tr:eq(1)>td>table>tbody>tr:has(td:gt(2))");
////*[@id="bill243489559255"]/td[2]/table/tbody
String line = null;
String queryDate = "2012-12-26";
for (int i = 1; i < lines.size(); i++) {
String date = lines.get(i).select("tr>td:eq(1)").get(0).text();
String state = lines.get(i).select("tr>td:eq(3)").get(0).text();
if ((!state.contains("签收人是"))
&& (date.equals(queryDate))) {//最新状态
String date0 = lines.get(i + 2).select("tr>td:eq(1)").get(0).select("table>tbody>tr:eq(1)>td:eq(0)").text();
if(date0.equals(queryDate)){//签收时间
String postcode = lines.get(i).select("tr>td:eq(0)").get(0)
.text();
String location = lines.get(i).select("tr>td:eq(4)").get(0)
.text();

line = postcode + "|" + date + "|" + location;
log.info(line);
idOkNum++;
System.out.println(line);
}
try {
Thread.currentThread().sleep(10000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
i = i + 2;
}

System.out.println("========================================================");
return idOkNum;
}

private void queryInit() {
String sidUrl = "http://kf.sf-express.com/css/myquery/trackSmallBywqs.action?locale=zh_CN&region=CN";
// JSESSIONID Received 6B6270A4A50F525A47CA1967D4B98CC7 / .kf.sf-express.com (Session) Server No No
// locale Received zh_CN / .kf.sf-express.com Tue, 25-Dec-2012 05:08:08 GMT Server No No
// SERVERID Received css9 / .kf.sf-express.com (Session) Server No No
// JSESSIONID Received 6B6270A4A50F525A47CA1967D4B98CC7 /
// .kf.sf-express.com (Session) Server No No
// locale Received zh_CN / .kf.sf-express.com Tue, 25-Dec-2012 05:08:08
// GMT Server No No
// SERVERID Received css9 / .kf.sf-express.com (Session) Server No No
getText(sidUrl);
}

private void genIds() {
// 读取文件
File idFile = new File("id.txt");

String line = null;
ArrayList<String> cLines = new ArrayList<String>();
for (int i = 0; i < 10000; i++) {

String idList = "";

int idOkNum = 0;
for (int i = 0; i < 100000 && idOkNum < 5; i++) {
String nextNum = genCheckNum(num);
line = nextNum;
cLines.add(line);
idList = idList + nextNum;

num = nextNum;

if ((i + 1) % 20 == 0) {
line = "";
cLines.add(line);
System.out.println("nextNum:" + nextNum);
idOkNum = idOkNum + queryIds20(idList);

idList = "";
} else {
idList = idList + "%0D%0A";
}

}

try {
FileUtils.writeLines(idFile, cLines);
} catch (IOException e) {
e.printStackTrace();
}
}

private void queryIds() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public Document handleResponse(HttpResponse response)
// TODO Auto-generated method stub
Document doc = null;
try{
// doc = Jsoup.parse(response.getEntity().getContent(), "UTF-8", "");
doc = Jsoup.parse(response.getEntity().getContent(), "gb2312", "");
doc = Jsoup.parse(response.getEntity().getContent(), "UTF-8", "");
// doc = Jsoup.parse(response.getEntity().getContent(), "gb2312", "");
}catch(TruncatedChunkException e){
e.printStackTrace();
}
Expand Down
3 changes: 2 additions & 1 deletion common.tools/src/main/resources/log4j.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
log4j.rootLogger=info, A1
log4j.logger.uims.common.tools.app.KDGen=debug,F1
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r %-5p [%t] %37c %3x - %m%n
log4j.appender.F1=org.apache.log4j.DailyRollingFileAppender
log4j.appender.F1.layout.ConversionPattern=%d{MM-dd HH:mm:ss.SSS} %-4r %-5p [%t] %37c %3x - %m%n
log4j.appender.F1.File=D:\\bbgg.txt
log4j.appender.F1.File=ids.txt
log4j.appender.F1.DatePattern='.'yyyy-MM-dd
log4j.appender.F1.Append=false
log4j.appender.F1.Threshold=INFO
Expand Down
Loading

0 comments on commit 37fc1b3

Please sign in to comment.