java script sign in page I am trying to scrape a table from a web page from my work with xml for speed advantages. I have posted the link but unfortunately you will not be able to sign in as it is behind a firewall.
I have manged to get the table with regular ie scraping but once I heard about xml, I knew that that was the way to go.
However, when I try sending credentials and checking the response, I keep seeing the response that I need to send credentials.
Sub test()
link = "http://w2tsl72/FAB-2_PROD/DmrListResults.asp?area=FAB&location=EPI&status=OP&Lot=ALL&waitTitle=ENG&waitBadge=18352&OpenFrom=ALL&OpenTo=ALL&CloseFrom=ALL&CloseTo=ALL&defect_cat=ALL&defect_group1=ALL&defect_group2=ALL&EightD=ALL&MRB=ALL&dmrType=ALL&EQUIP=ALL&NCMR=ALL&SOLAN=ALL&prod="
With CreateObject("MSXML2.XMLHttp")
.Open "get", link, False, "xxxx", "xxxxx"
.send
htmlDoc.body.innerHTML = .responseText
Debug.Print .responseText
End With
End Sub
Second attempt:
Sub test23()
link = "http://w2tsl72/FAB-2_PROD/Login.asp"
With CreateObject("MSXML2.XMLHttp")
.Open "get", link, False
.send
htmlDoc.body.innerHTML = .responseText
htmlDoc.getElementById("text1").Value = "xxxx"
htmlDoc.getElementById("password1").Value = "xxxxx"
htmlDoc.getElementById("submit1").Click
link = "http://w2tsl72/FAB-2_PROD/DmrListResults.asp?area=FAB&location=EPI&status=OP&Lot=ALL&waitTitle=ENG&waitBadge=18352&OpenFrom=ALL&OpenTo=ALL&CloseFrom=ALL&CloseTo=ALL&defect_cat=ALL&defect_group1=ALL&defect_group2=ALL&EightD=ALL&MRB=ALL&dmrType=ALL&EQUIP=ALL&NCMR=ALL&SOLAN=ALL&prod="`
End With
End Sub
I assume that I have signed in and now I want to navigate to the link above with xml.
After making corrections suggested by Wayne, is this what you mean?
Sub test23()
link = "http://w2tsl72/FAB-2_PROD/Login.asp"
Dim response As String
UserName = "xxxx"
Password = "xxxx"
With XMLPage
.Open "post", link, False
.setRequestHeader "Cookie", "ASPSESSIONIDQSRASDCT=EPKEOALBCAIKKCHNEGBKJJJG"
.setRequestHeader "Authorization", "Basic " + Base64Encode(UserName + ":" + Password)
.send
htmlDoc.body.innerHTML = .responseText
End With
link = "http://w2tsl72/FAB-2_PROD/DmrListResults.asp?area=FAB&location=EPI&status=OP&Lot=ALL&waitTitle=ALL&waitBadge=18352&OpenFrom=ALL&OpenTo=ALL&CloseFrom=ALL&CloseTo=ALL&defect_cat=ALL&defect_group1=ALL&defect_group2=ALL&EightD=ALL&MRB=ALL&dmrType=ALL&EQUIP=ALL&NCMR=ALL&SOLAN=ALL&prod="
With XMLPage
.Open "GET", link, False
.setRequestHeader "Cookie", "ASPSESSIONIDQSRASDCT=EPKEOALBCAIKKCHNEGBKJJJG"
.send
htmlDoc.body.innerHTML = .responseText
End With
End Sub
new code attempt
Sub post_frm()
Dim objIE As Object, xmlhttp As Object
Dim response As String
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate "about:blank"
objIE.Visible = True
Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
'~~> Indicates that page that will receive the request and the type of request being submitted
xmlhttp.Open "post", "http://w2tsl72/FAB-2_PROD/Login.asp", False
'~~> Indicate that the body of the request contains form data
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
'~~> Send the data as name/value pairs
xmlhttp.send "text1=xxxx&password1=xxxx"
response = xmlhttp.responseText
objIE.Document.write response
Set xmlhttp = Nothing
End Sub