99
1010import cn .hutool .core .codec .Base64 ;
1111import cn .hutool .core .util .CharsetUtil ;
12+ import cn .hutool .core .util .StrUtil ;
1213import cn .hutool .core .util .URLUtil ;
1314import cn .hutool .http .HttpResponse ;
1415import cn .hutool .json .JSONArray ;
1516import cn .hutool .json .JSONObject ;
1617import cn .hutool .log .Log ;
1718import cn .hutool .log .LogFactory ;
19+ import zimu .util .ExeJsUtil ;
1820import zimu .util .HtHttpUtil ;
1921import zimu .util .StringUtil ;
2022import zimu .util .regex .RegexUtil ;
@@ -33,9 +35,9 @@ public class ZIMuKuCommon {
3335
3436 public static void main (String [] args ) throws Exception {
3537 //System.out.println(DownList("憨豆特工.mkv"));
36- System .out .println (DownList ("downsizing.2017.720p.bluray.x264-geckos.mkv" ));
37-
38-
38+ // System.out.println(DownList("downsizing.2017.720p.bluray.x264-geckos.mkv"));
39+ System . out . println ( DownList ( "From.Beijing.with.Love.1994.720p.BluRay.x264-WiKi.mkv" ));
40+ //System.out.println(getPageList("From.Beijing.with.Love"));
3941
4042 //System.out.println(downContent("/detail/101779.html"));;
4143 //detail/100250.html
@@ -67,13 +69,13 @@ public static JSONArray DownList(String fileName) throws Exception {
6769 * @return
6870 */
6971 public static JSONObject downContent (String url ) {
70- String result = HtHttpUtil . http . get (baseUrl +url );
72+ String result = httpGet (baseUrl +url );
7173 String downUrl = RegexUtil .getMatchStr (result ,
7274 "<a\\ s+id=\" down1\" \\ s+href=\" (/dld/[\\ w]+\\ .html)\" "
7375 , Pattern .DOTALL );
7476 if (downUrl == null )return null ;
7577 downUrl = baseUrl + downUrl ;
76- result = HtHttpUtil . http . get (downUrl );
78+ result = httpGet (downUrl );
7779 if (result == null )return null ;
7880 //System.out.println(result);
7981 JSONArray resList = RegexUtil .getMatchList (result ,
@@ -102,7 +104,7 @@ public static JSONObject downContent(String url) {
102104 * @return
103105 */
104106 public static JSONArray getDetailList (String url ) {
105- String result = HtHttpUtil . http . get (baseUrl +url );
107+ String result = httpGet (baseUrl +url );
106108 //System.out.println(result);
107109 Document doc = Jsoup .parse (result );
108110 Elements matchList = doc .select ("#subtb tbody tr" );
@@ -189,7 +191,7 @@ public static JSONArray getFuzzyPageList(String title) {
189191 * @return
190192 */
191193 public static JSONArray getPageList (String title ) {
192- String result = HtHttpUtil . http . get (baseUrl +"/search?q=" +URLUtil .encodeAll (title , CharsetUtil .CHARSET_UTF_8 ));
194+ String result = httpGet (baseUrl +"/search?q=" +URLUtil .encodeAll (title , CharsetUtil .CHARSET_UTF_8 ));
193195 //System.out.println(result);
194196 JSONArray resList = RegexUtil .getMatchList (result , "<p\\ s+class=\" tt\\ s+clearfix\" ><a\\ s+href=\" (/subs/[\\ w]+\\ .html)\" \\ s+"
195197 + "target=\" _blank\" ><b>(.*?)</b></a></p>" , Pattern .DOTALL );
@@ -200,4 +202,26 @@ public static JSONArray getPageList(String title) {
200202
201203 return resList ;
202204 }
205+
206+ public static String httpGet (String url ) {
207+ String result = HtHttpUtil .http .get (url );
208+ if (result !=null && StrUtil .count (result , "url" )>10 && result .contains ("<script" )) {
209+ String jsStr = RegexUtil .getMatchStr (result , "<script[^>]*>(.*?)</script>" );
210+ jsStr = jsStr .replaceAll ("window.location[\\ s]*=[\\ s]*url" , "" );
211+ jsStr = jsStr .replaceAll ("location[\\ s]*=[\\ s]*url" , "" );
212+ if (jsStr ==null ) {
213+ jsStr = "" ;
214+ }
215+ String jsVal = null ;
216+ try {
217+ jsVal = ExeJsUtil .getJsVal ("function getUrl(){" +jsStr +";return url;} getUrl()" );
218+ }catch (Exception e ) {
219+ logger .error (e );
220+ }
221+ if (jsVal !=null &&jsVal .length ()>0 ) {
222+ return httpGet (jsVal .contains ("://" ) ? jsVal : baseUrl +jsVal );
223+ }
224+ }
225+ return result ;
226+ }
203227}
0 commit comments