+ Reply to Thread
Results 1 to 8 of 8

Trouble saving a websites source code to a text file.

  1. #1
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Trouble saving a websites source code to a text file.

    I know there are much easier ways to accomplish this in other languages but I thought I'd give it a go in VBA.

    Please Login or Register  to view this content.
    The above will throw an error and the only reason I can think of is because you can't write more than a specified amount of characters to a file using a.Writeline. How would I get this code to work with any size of text?

    This code comes from 2 places...

    http://stackoverflow.com/questions/1...de-buffer-size

    and

    http://www.excelforum.com/excel-prog...o-notepad.html
    Last edited by 111StepsAhead; 04-12-2013 at 09:12 AM.

  2. #2
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Re: Trouble saving a websites source code to a text file.

    Elaborating on my earlier assumption. I tested 3 webpages number of characters in the source code.

    page 1) 65,094
    page 2) 95,894
    page 3) 128,597

    Only page 1 worked with no errors. If I had to guess, anything over 2^16 characters is going to give me issues. Any advice here is appreciated.

  3. #3
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Re: Trouble saving a websites source code to a text file.

    My updated version is this. I try to parse the string but am unable too.

    Please Login or Register  to view this content.

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Trouble saving a websites source code to a text file.

    Please Login or Register  to view this content.



  5. #5
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Re: Trouble saving a websites source code to a text file.

    Thanks snb. You make VBA seem much easier than I ever could. The only issue is that code doesn't seem to work for Google's homepage. I will never really need to get Google's source code so it's not a problem. Thanks for your help.

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Trouble saving a websites source code to a text file.

    Set reference to Microsoft XML version 2.0

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Re: Trouble saving a websites source code to a text file.

    I'm not as familiar with XML as VBA. snb, Can you elaborate on what it means to set reference to Microsoft XML version 2.0?

    My other issue is getting a real response from a website versus a fake one. It seems the site I was attempting to webscrape can differentiate between a real request and an automated request.

  8. #8
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Re: Trouble saving a websites source code to a text file.

    Still can't get Google to work but many other sites do work with this code I found here: http://www.jpsoftwaretech.com/vba/ms...rary-routines/
    I guess I haven't figured out the XML world yet but I will keep digging.

    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)

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