Consulting

Results 1 to 4 of 4

Thread: Email scrape from website

  1. #1

    Email scrape from website

    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...


    [VBA] 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/"
    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
    [/VBA]
    ......................

    My very boring Running Blog

  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    Ride the wind to the sun
    Posts
    2,591
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  3. #3
    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
    Attached Files Attached Files
    ......................

    My very boring Running Blog

  4. #4
    Good morning.
    Could you update the code of this macro?
    Thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •