Sharid
Well-known Member
- Joined
- Apr 22, 2007
- Messages
- 1,066
- Office Version
- 2016
- Platform
- Windows
I need to refine this part of my code, I was thinking maybe as an IF statement, So if
dd(1) = "@" then data is pasted into sheet1 column A starting at row 2
dd(2) = "http:" or "https" then data does into sheet1 column B starting at row 2
Problem is the (2).innerText and (3).innerText can have either or other text,
I don't want other text only emails and URLS in Sheet1
So Sheet1 "Scraper" should look like this
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]Emails[/TD]
[TD]URL[/TD]
[/TR]
[TR]
[TD]John@mysite.com[/TD]
[TD]http://mysite.com[/TD]
[/TR]
[TR]
[TD]Jane@gmail.com[/TD]
[TD]https://yoursite.com[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Currently its all over the place.
Important - Data has to go in next blank row, so emails and urls match
Thanks for having a look
dd(1) = "@" then data is pasted into sheet1 column A starting at row 2
dd(2) = "http:" or "https" then data does into sheet1 column B starting at row 2
Problem is the (2).innerText and (3).innerText can have either or other text,
I don't want other text only emails and URLS in Sheet1
So Sheet1 "Scraper" should look like this
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]Emails[/TD]
[TD]URL[/TD]
[/TR]
[TR]
[TD]John@mysite.com[/TD]
[TD]http://mysite.com[/TD]
[/TR]
[TR]
[TD]Jane@gmail.com[/TD]
[TD]https://yoursite.com[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Currently its all over the place.
Code:
'Variable for document or data which need to be extracted out of webpage, change innertext number if same class used
Dim doc As HTMLDocument
Set doc = ie.document
dd(1) = doc.getElementsByClassName("_50f4")(2).innerText
dd(2) = doc.getElementsByClassName("_50f4")(3).innerText
'On Error Resume Next
'Paste in this sheet
With Sheet1
.Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Resize(, 2).Value = dd
End With
Important - Data has to go in next blank row, so emails and urls match
Thanks for having a look
Last edited: