site authentication VBA

Asked

Viewed 67 times

2

I’m scraping a site and I’m putting the cookie authentication, has to be by Mozilla.

I am provisionally using Cookie authentication

.setRequestHeader "Cookie", "JSESSIONID=...


I created this sub that authenticates, but how to join to my main code that is scraping.

Public Sub Login()

    Dim xmlhttp As New MSXML2.XMLHTTP60
    Dim myurl As String

    myurl = "URL"

    xmlhttp.Open "POST", myurl, False

    xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

    xmlhttp.setRequestHeader "Connection", "keep-alive"

    xmlhttp.send "login=LOGIN&senha=SENHA"



    MsgBox (xmlhttp.responseText)

    End Sub

This Routine logs in to the site, but I have another code that does the scraping needs to join the authentication, before scraping .setRequestHeader "Connection", "keep-alive" 'DIDN’T RESOLVE

.setRequestHeader "Authorization", "LOGIN" & "SENHA" 'DIDN’T RESOLVE

xmlhttp.send "login=LOGIN&senha=SENHA" 'DIDN’T RESOLVE

I’m using two Urls one to log in and the other to scrape but nothing happens as if I haven’t logged in, the two sub separately work.

  • You’ve already followed through the browser, to see what request the browser makes, and what headers it sends?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.