简体   繁体   中英

jsoup parse from website redirect

I am parsing from this url , but I have a problem with ajax load. When I parse this website it show me only body without response I need body of elememt ticket_lists . I dont know how redirect on this website is working. I tried debug js in debugger but without success. I am using jsoup. It is possible?

Thank you

Connection.Response response = Jsoup.connect("https://jizdenky.studentagency.cz/Booking/from/1763018002/to/10202038/tarif/REGULAR/departure/20160711/retdep/20160711/return/false/ropen/false/credit/false/class/2")
                .method(Connection.Method.GET)
                .execute();
Map<String,String> cookies = response.cookies();

Document doc = Jsoup.connect("https://jizdenky.studentagency.cz/Booking/from/1763018002/to/10202038/tarif/REGULAR/departure/20160711/retdep/20160711/return/false/ropen/false/credit/false/class/2?1")
                .userAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36")
                .cookies(cookies)
                .get();
System.out.print(doc.body());

If you open your browser's developer tools, You'll see that after requesting the first page, the browser is redirected, and send (among other things) an XHR request (which is actually an AJAX ):
在此处输入图片说明 The response to that request contains the information you need.
Check the parameters that the browser is sending and do the same.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM