Home > Blockchain >  Scrape data from multiple url in excel and save it in different row
Scrape data from multiple url in excel and save it in different row

Time:08-27

getting url form sheet1 range a1:a1000 and after exporting saving data too sheet2

ie.navigate Workbooks("1000").Worksheets("sheet1").Range("A6").Value

Set ht = ie.document
Workbooks("1000").Worksheets("sheet2").Range("C6").Value = ht.getElementById("formNo").Value
Workbooks("1000").Worksheets("sheet2").Range("D6").Value = ht.getElementById("fullName").Value
Workbooks("1000").Worksheets("sheet2").Range("E6").Value = ht.getElementById("idNo").Value

CodePudding user response:

I do not what exactly is that you want. But I am providing a code snippet with which you can achieve your task by simply modifying it.

Sub Scrape()

Dim url As String
Dim IE As New InternetExplorer
Dim doc As HTMLDocument

Set IE = New InternetExplorer
IE.Visible = False

For Each cell In Range("A1:A1000")

url = cell.Value

IE.navigate url

Do
DoEvents
Loop Until IE.readyState = READYSTATE_COMPLETE

Set doc = IE.document

Sheet2.Range("A1").Value = doc.getElementsByTagName("span")(0).innerText
Sheet2.Range("A2").Value = doc.getElementsByTagName("span")(1).innerText
Sheet2.Range("A3").Value = doc.getElementsByTagName("span")(2).innerText
Sheet2.Range("A4").Value = doc.getElementsByTagName("span")(3).innerText


Next cell

IE.Quit

End Sub
  • Related