PDA

View Full Version : Email scrape from website



rossmiddleto
09-27-2011, 09:16 AM
Hi All,

I am trying to learn how to navigate web pages using internet explorer and VBA in Excel.

What I would like to do is to go to the following web page (allyouneedtotri.com/directory/listing/clubs-and-training-venues/159/triathlon-clubs), navigate to each 'more info' page and download all the email addresses from the 'more details' pages into a sheet (there is only one in each of the 'more details' tabs)

I would then like the macro to click the number 2 on the page allyouneedtotri.com/directory/listing/clubs-and-training-venues/159/triathlon-clubs, to display the next 10 items and then the macro needs to go to each of their 'more info' pages and download the email address from each page.

I have made a few attempts but I have made a complete mess of the code and nothing seems to work.

If someone could write the first part of the code so that I can have a look and learn from it then that would be awesome

Regards

Ross

My pitiful attempt at the initial part of the macro...


Sub emails1()

Dim IE As InternetExplorer
Dim RegEx As Variant, RegMatch As Variant
Dim MyStr As String

Set IE = New IE
Set RegEx = New RegExp


IE.Navigate "http://www.allyouneedtotri.com/direc...iathlon-clubs/ (http://www.allyouneedtotri.com/directory/listing/clubs-and-training-venues/159/triathlon-clubs/)"
Do Until IE.ReadyState = READYSTATE_COMPLETE
Loop

'String to parse google search for a VBAX reference
With RegEx
.Pattern = "wp-content/themes/ayntt/images/more-detail-button.png"
.MultiLine = True
End With

'return text from google page
MyStr = IE.Document.body.innertext
Set RegMatch = RegEx.Execute(MyStr)

'If a match to our RegExp searchstring is found then launch this page
If RegMatch.Count > 0 Then
IE.Navigate RegMatch(0)
Do Until IE.ReadyState = READYSTATE_COMPLETE
Loop
MsgBox "Loaded VBAX link"
'show internet explorer
IE.Visible = True
Else
MsgBox "No VBAX link found"
End If

Set RegEx = Nothing
Set IE = Nothing
End Sub

mancubus
09-28-2011, 05:25 AM
crossposted:
http://www.mrexcel.com/forum/showthread.php?t=581621

pls refer to for x-posting:
http://vbaexpress.com/forum/showthread.php?t=6905

rossmiddleto
09-28-2011, 05:40 AM
Thanks for this - i didnt realise that cross posting was such an issue but after reading the article I can completely see how frustrating it must be for someone to work on a soultion to a problem to find that it has already been answered in another post. I worked out a solution to my original problem about half an hour ago

stefanoste78
04-16-2019, 02:08 AM
Good morning.
Could you update the code of this macro?
Thank you