麻烦使用JSOUP中的post参数来获得正确的响应

时间:2013-12-21 07:31:40

标签: java web-scraping jsoup

我想抓住亚航网站的屏幕,并获得输入日期的票价。

我选择墨尔本到雅加达和雅加达到墨尔本作为目的地, 2014年1月8日离开,2014年1月15日返回。

到目前为止我尝试过:

  1. 我使用firebugs复制了所有post参数

    ControlGroupSearchView$AvailabilitySearchInputSearchView$DropDownListMarketDay1=8
    ControlGroupSearchView$AvailabilitySearchInputSearchView$DropDownListMarketDay2=15
    ControlGroupSearchView$AvailabilitySearchInputSearchView$DropDownListMarketMonth1=2014-01
    ControlGroupSearchView$AvailabilitySearchInputSearchView$DropDownListMarketMonth2=2014-01
    ControlGroupSearchView$AvailabilitySearchInputSearchView$DropDownListPassengerType_ADT=1
    ControlGroupSearchView$AvailabilitySearchInputSearchView$DropDownListPassengerType_CHD=0
    ControlGroupSearchView$AvailabilitySearchInputSearchView$DropDownListPassengerType_INFANT=0
    ControlGroupSearchView$AvailabilitySearchInputSearchView$DropDownListSearchBy=columnView
    ControlGroupSearchView$AvailabilitySearchInputSearchView$RadioButtonMarketStructure=RoundTrip
    ControlGroupSearchView$AvailabilitySearchInputSearchView$TextBoxMarketDestination1=CGK
    ControlGroupSearchView$AvailabilitySearchInputSearchView$TextBoxMarketOrigin1=MEL
    ControlGroupSearchView$ButtonSubmit=Search
    ControlGroupSearchView$MultiCurrencyConversionViewSearchView$DropDownListCurrency=5027457818
    ControlGroupSearchView_AvailabilitySearchInputSearchViewdestinationStation1=CGK
    ControlGroupSearchView_AvailabilitySearchInputSearchVieworiginStation1=MEL
    MemberLoginSearchView$HFTimeZone=420
    __EVENTARGUMENT=
    __EVENTTARGET=
    __VIEWSTATE=/wEPDwUBMGRktapVDbdzjtpmxtfJuRZPDMU9XYk=
    date_picker=01/08/2014
    date_picker=
    date_picker=01/15/2014
    date_picker=
    pageToken=
    
  2. 我使用Jsoup框架作为废弃工具

    public static void main(String[] args) {
    
    Document doc;
    
    try {
    
    
        doc =   Jsoup.connect("http://booking.airasia.com/Search.aspx")
    
                .data("ControlGroupAvailabilitySearchInputSelectView$AvailabilitySearchInputSelectView$DropDownListMarketDay1","8")
                .data("ControlGroupAvailabilitySearchInputSelectView$AvailabilitySearchInputSelectView$DropDownListMarketDay2","15")
                .data("ControlGroupAvailabilitySearchInputSelectView$AvailabilitySearchInputSelectView$DropDownListMarketMonth1","2014-01")
                .data("ControlGroupAvailabilitySearchInputSelectView$AvailabilitySearchInputSelectView$DropDownListMarketMonth2","2014-01")
                .data("ControlGroupAvailabilitySearchInputSelectView$AvailabilitySearchInputSelectView$DropDownListPassengerType_ADT","1")
                .data("ControlGroupAvailabilitySearchInputSelectView$AvailabilitySearchInputSelectView$DropDownListPassengerType_CHD","0")
                .data("ControlGroupAvailabilitySearchInputSelectView$AvailabilitySearchInputSelectView$DropDownListPassengerType_INFANT","0")
                .data("ControlGroupAvailabilitySearchInputSelectView$AvailabilitySearchInputSelectView$DropDownListSearchBy","columnView")
                .data("ControlGroupAvailabilitySearchInputSelectView$AvailabilitySearchInputSelectView$RadioButtonMarketStructure","RoundTrip")
                .data("ControlGroupAvailabilitySearchInputSelectView$AvailabilitySearchInputSelectView$TextBoxMarketDestination1","CGK")
                .data("ControlGroupAvailabilitySearchInputSelectView$AvailabilitySearchInputSelectView$TextBoxMarketOrigin1","MEL")
                .data("ControlGroupAvailabilitySearchInputSelectView$ButtonSubmit","Search")
                .data("ControlGroupAvailabilitySearchInputSelectView$MultiCurrencyConversionViewSelectView$DropDownListCurrency","5027457818")
                .data("ControlGroupAvailabilitySearchInputSelectView_AvailabilitySearchInputSelectViewdestinationStation1","CGK")
                .data("ControlGroupAvailabilitySearchInputSelectView_AvailabilitySearchInputSelectVieworiginStation1","MEL")
                /*.data("MemberLoginSelectView$HFTimeZone","420")
                .data("__VIEWSTATE","/wEPDwUBMGRktapVDbdzjtpmxtfJuRZPDMU9XYk=")
                .data("__EVENTARGUMENT" , "")
                .data("__EVENTTARGET" ,"")
                */
                 .post();
    
        System.out.println(doc);
    
    
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    
    }
    
  3. 我没有得到我想要的回复。

    有人能告诉我我的代码有什么问题吗?

0 个答案:

没有答案