[Zope] calling PythonScript on another machine
   
    Paul Winkler
     
    pw_lists@slinkp.com
       
    Wed, 28 Aug 2002 13:23:36 -0700
    
    
  
On Wed, Aug 28, 2002 at 02:59:28PM -0400, Kevin Carlson wrote:
> Could you do this by using httplib and urllib in an external script:
I do pretty much the same thing to slurp some content from
another web app. server (which shall remain nameless) into Zope.
Here's the relevant bit (tested and working as an external method):
def pagesuck(site="http://www.foo.com", page="path/to/object"):
    remote = httplib.HTTP(site)
    remote.putrequest('GET', page)
    remote.putheader('Accept', 'text/html')
    remote.putheader('Accept', 'text/plain')
    remote.endheaders()
    errcode, errmsg, headers = remote.getreply()
    if errcode != 200:
        return "Could not open the page. Error %d: %s" % (errcode, errmsg)
    f = remote.getfile()
    data = f.read()
    f.close()
 
--
Paul Winkler
"Welcome to Muppet Labs, where the future is made - today!"