+ Reply to Thread
Results 1 to 2 of 2

Beginner question about scraping web pages with Excel VBA

  1. #1
    Registered User
    Join Date
    04-13-2012
    Location
    New Jersey
    MS-Off Ver
    Excel 2007
    Posts
    3

    Question Beginner question about scraping web pages with Excel VBA

    Hello everyone,

    I'm trying to do the following:

    1. Visit a website
    2. Fill out an input box
    3. Click Submit
    4. Scrape text from the resulting webpage

    I've pasted my current code at the end of this post. For some reason, that last htmlDoc.body.innerHTML shows the body of the first webpage, not the new webpage after the submit button was clicked. I assumed that by saying Set htmlDoc = objIE.Document after clicking submit, it sets htmlDoc as the new active webpage, so when I grab the body text, it should grab the text from the second page, no?

    I'm really new to all this, so if anyone has a link to a primer on scraping data from web pages with Excel, it would be greatly appreciated as well.

    Please Login or Register  to view this content.
    Last edited by sheilnaik; 03-28-2013 at 11:44 AM.

  2. #2
    Registered User
    Join Date
    04-13-2012
    Location
    New Jersey
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Beginner question about scraping web pages with Excel VBA

    Realized the problem. I needed to add Application.Wait (Now + TimeValue("0:00:05")) before Set htmlDoc at the end. The webpage wasn't fully loaded before it "reset" the htmlDoc variable for the new page. It works now!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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