Re: view page source or save after load



zephron2000 wrote:
I need to either:
1. View the page source of a webpage after it loads
or
2. Save the webpage to my computer after it loads (same as File > Save
Page As)
urllib is not sufficient (using urlopen or something else in urllib
isn't going to do the trick)

You don't really say _why_ urllib.urlopen "isn't going to do the
trick". The following does what you've described:

import urllib
page = urllib.urlopen('http://some.address')
open('saved_page.txt','w').write(page).close()

If you're needing to use a browser directly and you're running under
Windows, try the Internet Explorer Controller library, IEC:

import IEC
ie = IEC.IEController()
ie.Navigate('http://some.address')
page = ie.GetDocumentHTML()
open('saved_page.txt','w').write(page.encode('iso-8859-1')).close()

(You can grab IEC from http://www.mayukhbose.com/python/IEC/index.php)

Hope this helps.

-alex23

.



Relevant Pages

  • Re: view page source or save after load
    ... Save the webpage to my computer after it loads (same as File> Save ... urllib is not sufficient (using urlopen or something else in urllib ... UCLA-DOE Institute for Genomics and Proteomics ...
    (comp.lang.python)
  • view page source or save after load
    ... Save the webpage to my computer after it loads (same as File> Save ... urllib is not sufficient (using urlopen or something else in urllib ... isn't going to do the trick) ...
    (comp.lang.python)
  • Re: The Empire Strikes Back
    ... There is a distinction between the webpage pulling in content and an "active ... it is not the web page doing it since the Flash SWF originated ... What matters is how the _web_page_ loads the external ...
    (borland.public.delphi.non-technical)
  • Re: Pressing A Webpage Button
    ... Elliot Temple writes: ... > How do I make Python press a button on a webpage? ... > urllib, but I only see how to open a URL with that. ...
    (comp.lang.python)
  • Re: How to receive events (eg. user mouse clicks) from IE
    ... as I switched the URL to a page that loads slowly, ... seems to allow both event hooks to run without blocking each other. ... > IE now loads the webpage and prompts the user. ... > invokes the Doc_Events method Ononactivate method. ...
    (comp.lang.python)