shahin
Active Member
While dealing with ".aspx" or ".php" or sites with extension like that it's very painful to pass "payload" parameter within "post" request in order to get a valid response. Today when I tried to buid a scraper using python for a ".aspx" site, I could find out that the logic I applied in python can be applied in vba as well to save the energy from writing "__viewstate", "__eventtarget", "__eventargument" etc. manually in the formdata. My below script can populate them dynamically. However, the only thing I need to fix is place them in a single line concatinating "=" and "&" to be able to generate a valid response from that target site.
This is my script so far:
The result it produces can be seen in the first text file attached below.
What I wish to do now is like this (few have values and few don't have):
How can i achive that? Thanks in advance.
FYI, the script is able to populate formdata (names and its corresponding values) from any site (the ones require post request). All it is needed to fix the "selector" to get them.
This is my script so far:
Code:
Sub GetInput()
Dim HTML As New HTMLDocument
Dim I&
With New XMLHTTP60
.Open "GET", "https://bccorreio.bcb.gov.br/bccorreio/Autenticacao/Logon.aspx?ReturnUrl=%2fbccorreio%2f", False
.send
HTML.body.innerHTML = .responseText
End With
With HTML.querySelectorAll("#form1 input")
For I = 0 To .Length - 1
R = R + 1: Cells(R, 1) = .item(I).getAttribute("name")
Cells(R, 2) = .item(I).getAttribute("value")
Next I
End With
End Sub
The result it produces can be seen in the first text file attached below.
What I wish to do now is like this (few have values and few don't have):
Code:
__LASTFOCUS=&__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=
How can i achive that? Thanks in advance.
FYI, the script is able to populate formdata (names and its corresponding values) from any site (the ones require post request). All it is needed to fix the "selector" to get them.
Attachments
Last edited: