Jsoup - 通过数据对象直接连接和连接

时间:2013-09-23 07:35:50

标签: jsoup

当我使用直接参数和througt数据对象时,我得到了2个不同的结果


测试1:直接连接

String url = "https://wl-prod.sabresonicweb.com/SSW2010/B3QE/webqtrip.html?searchType=NORMAL&lang=en&journeySpan=OW&origin=NGO&destination=SGN&numAdults=1&numChildren=0&numInfants=0&promoCode=&alternativeLandingPage=true&departureDate=2013-12-27";

            Document doc = Jsoup
                    .connect(url)                    
                    .userAgent("Mozilla")
                    .get();
            Element tableE = doc.getElementById("dtcontainer-both");
            System.out.println(tableE.html());

- >注意最后一行:货币是JPY


测试2:使用数据对象

String url = "https://wl-prod.sabresonicweb.com/SSW2010/VNVN/webqtrip.html";
            Map<String, String> data = new HashMap<String, String>();
            data.put("searchType", "NORMAL");
            data.put("lang", "en");            
            data.put("journeySpan", "OW");
            data.put("origin", "NGO");
            data.put("destination", "SGN");
            data.put("numAdults", "1");
            data.put("numChildren", "0");
            data.put("numInfants", "0");
            data.put("promoCode", "");
            data.put("alternativeLandingPage", "true");
            data.put("departureDate", "2013-12-27");

            Document doc = Jsoup
                    .connect(url)
                    .data(data)                                        
                    .userAgent("Mozilla")
                    .get();
            Element tableE = doc.getElementById("dtcontainer-both");
            System.out.println(tableE.html());

- &GT;注意最后一行:货币是VND

有人可以告诉我哪里错了吗?

2 个答案:

答案 0 :(得分:0)

我认为您的网址不同:

1) "https://wl-prod.sabresonicweb.com/SSW2010/B3QE/webqtrip.html"
2) "https://wl-prod.sabresonicweb.com/SSW2010/VNVN/webqtrip.html"

注意:B3QE!= VNVN

我没有对此进行测试,因此您可能还有其他因素干扰...

答案 1 :(得分:0)

看起来您的两个网址路径不同:一个包含B3QE,另一个包含VNVN。