+ Reply to Thread
Results 1 to 2 of 2

Scrape data Using getElementsbyTagName NOT WORKING

  1. #1
    Registered User
    Join Date
    04-24-2015
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    6

    Post Scrape data Using getElementsbyTagName NOT WORKING

    I am trying to navigate through a website by using getElementsbyTagName and then hopefully scrape data. It appears after my first trial it does not work and there is an error.
    Could someone give me some advice on where I am going wrong. i've noticed T in innertext is capitalised as well if that makes a difference.
    I only seem to get "one" Msgbox though and of course the beautiful Run time error '70' . Permission denied.

    This is my code, :
    [code]
    sub Scrape()
    Set ie = CreateObject("InternetExplorer.Application")
    ie.Visible = True
    ie.Top = 0
    ie.Left = 0
    ie.Width = 800
    ie.Height = 600

    URL = "http://www.ira.go.ke/"

    ie.Navigate URL
    Do
    DoEvents
    If Err.Number <> 0 Then
    ie.Quit
    Set ie = Nothing
    Goto the_start:
    End If

    Loop Until ie.ReadyState = 4
    Dim Doc As HTMLDocument
    Set Doc = ie.Document
    Dim Std As String

    Set AllLinks = Doc.getElementsByTagName("a")

    For Each hyperlink In AllLinks

    If InStr(hyperlink.href, "/index.php/acts") > 0 Then
    hyperlink.Click

    Exit For
    End If
    Next
    'going on to the next website
    Do
    DoEvents
    If Err.Number <> 0 Then
    ie.Quit
    Set ie = Nothing
    Goto the_start:
    End If
    Loop Until ie.ReadyState = 4
    ' it is fine up till this point

    Set AllLinks = Doc.getElementsByTagName("a")
    For Each hyperlink In AllLinks
    MsgBox hyperlink.innerText & " - " & hyperlink.href
    Next
    End Sub
    ' it loops once for the search but then I get a debugging error
    [\code]

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Scrape data Using getElementsbyTagName NOT WORKING

    I have removed the error trapping and seems to work but I do not know what are you supposed to scrape.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Data Scrape from webpage
    By arnoldchadd in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-16-2014, 07:31 AM
  2. [SOLVED] Web data scrape problem
    By Sean Thomas in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-06-2013, 07:35 AM
  3. VBA to scrape data from website
    By jdub22cb in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-16-2012, 04:00 PM
  4. VBA to control web page and scrape data
    By CharlieSierra in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-05-2008, 10:50 PM
  5. MSXML2 - getElementsByTagName()
    By hoopz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-09-2006, 03:41 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1