• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Web scraping VBA but stuck

Safat1

New Member
Hello Respectable Members,

I am trying to web scrape from a page but for that I need to log into an website inside another.

I have attached my VBA, if you open the excel an click on macro button it logs me onto the 1st website but then it needs to enter the following information onto the 2nd part of the login section:

Company number: 00161619
Authentication code: password

Because of confidentiality, I have not given the real password above but at least it should enter those login credential onto the 2nd part of the login detail section.

But for some reason, it logs me OK onto the 1st section and then does nothing to enter the above credential onto the 2nd part, if I can log into the 2nd part, I will then be able to scrape data.

I will appreciate if someone could help me with the above.

I have attached the VBA spreadsheet here.

Thanks,
S
 

Attachments

Marc L

Excel Ninja
Hello, according to your attachment a VBA demonstration as a beginner starter :​
Code:
Sub DemoIE1()
         Const cSIP = "companySignInPage."
         On Error GoTo Fin
    With New InternetExplorer
         .Silent = True
         .Navigate "https://ewf.companieshouse.gov.uk"
.Visible = True
          While .Busy Or .ReadyState < 4:  DoEvents:  Wend
    With .Document.all
         .email.Value = "…"
         .seccode.Value = "…"
         .submit.Click
    End With
          While .Document.ReadyState <> "complete":  DoEvents:  Wend
    With .Document.all
         .Item(cSIP & "coNum").Value = [A2].Text
         .Item(cSIP & "authCode").Value = "…"
         .Item(cSIP & "submit").Click
    End With
Fin:
Stop
         If Err.Number <> -2147023706 Then .Quit
    End With
         If Err.Number Then Beep: Debug.Print Err.Number; " : "; Err.Description
End Sub
Do you like it ? So thanks to click on bottom right Like !​
 
Top