I'm trying to do an scrape a web page but in order to Post the data I need a web session ID like
web_session=HQJ3G1GPAAHRZGFR
How can I get that ID?
My code so far is:
Private Sub test()
Dim postData As String = "web_session=HQJ3G1GPAAHRZGFR&intext=O&term_code=201210&search_type=A&keyword=&kw_scope=all&kw_opt=all&subj_code=BIO&crse_numb=205&campus=*&instructor=*&instr_session=*&attr_type=*&mon=on&tue=on&wed=on&thu=on&fri=on&sat=on&sun=on&avail_flag=on" '/BANPROD/pkgyc_yccsweb.P_Results
Dim tempCookie As New CookieContainer
Dim encoding As New UTF8Encoding
Dim byteData As Byte() = encoding.GetBytes(postData)
System.Net.ServicePointManager.SecurityProtocol = Net.SecurityProtocolType.Ssl3
Try
tempCookie.GetCookies(New Uri("https://taylor.yc.edu/BANPROD/pkgyc_yccsweb.P_Results"))
'postData="web_session=" & tempCookie.
Dim postReq As HttpWebRequest = DirectCast(WebRequest.Create("https://taylor.yc.edu/BANPROD/pkgyc_yccsweb.P_Results"), HttpWebRequest)
postReq.Method = "POST"
postReq.KeepAlive = True
postReq.CookieContainer = tempCookie
postReq.ContentType = "application/x-www-form-urlencoded"
postReq.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.0.3705; Media Center PC 4.0; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"
postReq.ContentLength = byteData.Length
Dim postreqstream As Stream = postReq.GetRequestStream
postreqstream.Write(byteData, 0, byteData.Length)
postreqstream.Close()
Dim postresponse As HttpWebResponse
postresponse = DirectCast(postReq.GetResponse, HttpWebResponse)
tempCookie.Add(postresponse.Cookies)
Dim postresreader As New StreamReader(postresponse.GetResponseStream)
Dim thepage As String = postresreader.ReadToEnd
MsgBox(thepage)
Catch ex As WebException
MsgBox(ex.Status.ToString & vbNewLine & ex.Message.ToString)
End Try
End Sub