1
ページはログインに戻ります。資格情報が要求に渡されることを確認しました。運がない。助けてください。私は次の日か2日にこれを行う必要があります。私がここで紛失しているものは何ですか?私は過去2日間このフォーラムに参加しましたが、それを理解できませんでした。これが重複していると申し訳ありません。HTTP投稿およびCSVファイルをダウンロードするダウンロード -
Dim response As Net.HttpWebResponse
Dim myURL1 As String
Dim response As Net.HttpWebResponse
Dim myURL1 As String
Dim myURL2 As String
Dim myURL3 As String
Dim cookieJar As New CookieContainer
Dim myReq As Net.HttpWebRequest
Dim strngData as String
' Network Credentials
Dim cred As New System.Net.NetworkCredential ("myLogin", "myPassword", ".genscape.com")
' Login Page URL
myURL1 = https://apps.genscape.com/NAPowerRT/login.jsp
'URL to scrape data
myURL2 = https://apps.genscape.com/NAPowerRT/planthistory.do?
plantid=9976&numDays=1&format=0/genscape-03_26_12-03_27_12-9708.csv
' Action URL in Form with method = POST
myURL3 = "https://apps.genscape.com/NAPowerRT/j_spring_security_check"
myReq = Net.HttpWebRequest.Create(myURL1)
myCache.GetCredential(myURL1, 0, "http")
myReq.Credentials = cred
'Get Cookies
myURL1 = "https://apps.genscape.com/NAPowerRT/login.jsp"
myReq = Net.HttpWebRequest.Create(myURL1)
myReq.UserAgent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"
myReq.Method = "GET"
myReq.CookieContainer = cookieJar
myReq.KeepAlive = True
response = myReq.GetResponse
For Each tempCookie As Net.Cookie In response.Cookies
cookieJar.Add(tempCookie)
Next
myReq.GetResponse.Close()
'Sent POST data
myReq = Net.HttpWebRequest.Create(myURL3)
myReq.UserAgent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"
myReq.Method = "Post"
myReq.AllowAutoRedirect = True
myReq.ContentType = "text/html"
myReq.Credentials = cred
myReq.CookieContainer = cookieJar
'Send request to URL that has data with cookies from previous GETs
' ----- The below results in login page instead of page where the csv is located
myReq = Net.HttpWebRequest.Create(myURL2)
myReq.Credentials = cred
myReq.Method = "get"
myReq.ContentType = "text/csv"
myReq.Accept = "text/html"
myReq.AllowAutoRedirect = True
myReq.KeepAlive = True
myReq.CookieContainer = cookieJar
'Get the data from the page
response = myReq.GetResponse
Dim streamreponse As Stream = response.GetResponseStream
Dim stream As StreamReader = New StreamReader(response.GetResponseStream())
strngData = stream.ReadToEnd()
response.Close()