Click here to Skip to main content
16,016,623 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: (untagged)
I want to take the Flight schedule from the following address:

Flight Schedule

If you paste the address to browser address bar and use firebug (or any fiddler), you will see this page sends 3 jquery ajax calls to bring the schedule. The following ajax POST actually fetch the schedule.

http://fo-apac.ttinteractive.com/Zenith/FrontOffice/(S(nves1yv4xxoia40cmotixof1))/USBangla/en-GB/FlexibleFlightStaticAjax/FlexibleFlightListLoadSelectedDays?__cnv=NEDGF

PostData :
SaleConditionAccepted=false&ExtendedSearchDayCount=3&DoNotCheckCache=false&AlreadyLoggedIn=false&Tem pDataGuid=nves1yv4xxoia40cmotixof1&CurrencyCode=BDT&FareBasisDataId=&Travelers[0][DataId]=1&Travelers[0][Count]=1&UserSelections[0][SelectedDate]=2016-04-27T00:00:00&UserSelections[0][ReferenceDate]=2016-04-27T00:00:00&UserSelections[0][DataIdOrigin]=6337&UserSelections[0][DataIdDestination]=6707&UserSelections[0][GenericClassDataId]=&UserSelections[0][SelectedSegments]=&JsonPrepareBookingRequest=&PromoCode=


What I have tried:

I am sending the request with httpwebrequest, but for unknown reason, I miss the session. I used CookieContainer to keep the cookies. I used the following function to send httprequest:

VB
Public Function GetPostWP(ByVal Url As String, ByVal CkCont As CookieContainer, Optional ByVal PostData As String = "", Optional ByVal refSite As String = "") As String
    Dim pStr As String = ""
    Try
        Dim Http As HttpWebRequest = WebRequest.Create(Url)
        If refSite <> "" Then Http.Referer = refSite
        Http.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate")

        Http.CookieContainer = CkCont  'Initial CkCont is Nothing
        Http.KeepAlive = True
        Http.AllowAutoRedirect = True

        'Http.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6"
        Http.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
        Http.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.137 Safari/537.36"

        If PostData <> "" Then
            Http.Method = "POST"
            Http.ContentLength = PostData.Length
            Http.ContentType = "application/x-www-form-urlencoded"

            Dim PostStream As StreamWriter = New StreamWriter(Http.GetRequestStream())
            PostStream.Write(PostData)
            PostStream.Close()
        End If

        Using WebResponse As HttpWebResponse = Http.GetResponse()
            Dim responseStream As Stream = WebResponse.GetResponseStream()

            If (WebResponse.ContentEncoding.ToLower().Contains("gzip")) Then
                responseStream = New GZipStream(responseStream, CompressionMode.Decompress)
            ElseIf (WebResponse.ContentEncoding.ToLower().Contains("deflate")) Then
                responseStream = New DeflateStream(responseStream, CompressionMode.Decompress)
            End If

            Dim reader As StreamReader = New StreamReader(responseStream, Encoding.Default)
            pStr = reader.ReadToEnd()

            responseStream.Close()
        End Using

        tmpCky = CkCont 'tmpCky is a Public CookieContainer Variable to hold cookies for future use.
        GetPostWP = pStr

    Catch ex As Exception
        GetPostWP = "Error : " & ex.Message
    End Try
End Function

    Dim Cky As New CookieContainer
    Dim Txt as String = GetPostWP(PostAddress, Cky, PostData, RefAdd)

    Cky = tmpCky



It is very urgent for my job. Can anyone analyze the page, please?

Thanks
Posted
Updated 11-Apr-16 17:46pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900