Home > Back-end >  Java how to crawl the headline hot information today
Java how to crawl the headline hot information today

Time:10-23

Occasionally try today, found that today's headline information data is by js request returns json data,
 https://www.toutiao.com/api/pc/feed/? Category=news_hot & amp; Utm_source=toutiao& Widen=1 & amp; Max_behot_time=0 & amp; Max_behot_time_tmp=0 & amp; Tadrequire=true& As=A1A59E854AA7874 & amp; Cp=5 e5ac7d827641e1 & amp; _signature=yC5W2AAgEBBvUdMRk. DUI8guF8AAJZ9R9DL8KANL4cGcw6L73vChOoUnbRLXCnSw7rxcy5egwT2p3fkpaKGMkwPRufmPZWSUWBpa21NhV9MN2gwLO1C5 itcexc 4-6 Yz1wWo 
is the link and find the as and cp parameter value is variable, from home_583c7a0. Js files found function
! 
The function (t) {
Var e={};
Um participant etHoney=function () {
Var t=Math. Floor ((new Date). GetTime ()/1 e3),
E=t.t oString (16). ToUpperCase (),
I=the md5 (t). The toString (). The toUpperCase ();
If (8!=e.l ength) return {
As: "479 bb4b7254c150",
Cp: "7 e0ac8874bb0985
"};
For (var n=i. lice (0, 5), a=i. lice (5), s="", o=0; 5 & gt; o; O++) s +=n + e [o] [o];
For (var r=", "
C=0; 5 & gt; c; C + +) r +=e/c + 3 + a [c];
Return {
As: "A1" + s + e.s lice (3),
Cp: e.s lice (0, 3) + r + "E1"
}
},
T.a SCP=e
} (Windows, document)
changed to Java method, but if not, the warrior to see which can also improve
 public static Map GetAsCp () {
As String="479 bb4b7254c150";
String cp="7 e0ac8874bb0985";
Int t=(int) (new Date (). The getTime ()/1000);
String e=Integer. ToHexString (t). The toUpperCase ();
String I=DigestUtils. Md5Hex (String. The valueOf (t) getBytes ()). The toUpperCase ();
If (e.l ength ()==8) {
Char [] n=i. ubstring (0, 5). ToCharArray ();
Char [] a=i. ubstring (i.l ength () - 5). ToCharArray ();
The StringBuilder s=new StringBuilder ();
The StringBuilder r=new StringBuilder ();
For (int o=0; o <5; O++) {
S.a ppend (n [o]). Append (e.s ubstring (o, o + 1));
Of state Richard armitage ppend (e.s ubstring (o + 3, + 4) o), append (a [o]);
}
As="A1" + s + e.s ubstring (e.l ength () - 3);
Cp=e.s ubstring (0, 3) + r + "E1";
}
Map The map=new HashMap<> (a);
The map. The put (" as ", as);
The map. The put (" cp ", cp);
return map;
}
, and finally the value of a parameter _signature also need a dynamic access?
  • Related