MATATA EMMANUEL wrote:
Alan,
Man! I was thinking that it was simple. This is a little bit hard but
will try to make sense of it as I can.
How would you fetch the shapefile with your browser? Is there a url to
download the file? It's pretty simple to fetch a web page or other
resource from a URL and save it to a local file. urllib.urlretrieve()
will do it.
If you have to authenticate (login) to the web site it gets a little
more complex. urllib2 is similar to urllib but it has more options and
supports authentication. There is a tutorial for urllib2 here:
Kent
Thank you for your assistance. I'm glad you're up there to assist.
Matt
From: /"Alan Gauld" <alan.gauld (AT) freenet (DOT) co.uk>/
To: /"MATATA EMMANUEL" <emmatata (AT) hotmail (DOT) com>/
CC: /<tutor (AT) python (DOT) org>/
Subject: /Re: [Tutor] Please help!!/
Date: /Sat, 20 May 2006 17:58:20 +0100/
>[CCing back to list]
>
>>I know HTML even if I haven't used it for sometimes. I Also know
>>couple other programming languages (Visual basic, some C++).
>>I just taken a Python course of writting Python scripts for ArcGIS
>>so that if you sent me a script, I will be able to understand it.
>
>K, now we know the background we know where to pitch the reply.
>I don't have a script that will do exactly what you want but someone
>else posted a snippet showing how to use urllib.
>
>If you need to parse the html that you read from urllib then you
>might
>find BeautifulSoup worth a look.
>
>
>
>It makes extracting elements from html fairly painless.
>
>But if its easy to find a simple search of the string for the img
>tag
>may suffice.
>
>HTH,
>
>Alan Gauld
>Author of the Learn to Program web site
>
>
>>
>From: "Alan Gauld" <alan.gauld (AT) freenet (DOT) co.uk>
>To: "MATATA EMMANUEL" <emmatata (AT) hotmail (DOT) com>,<Tutor (AT) python (DOT) org>
>Subject: Re: [Tutor] Please help!!
>Date: Sat, 20 May 2006 13:15:41 +0100
>>>I'm tasked to write a Paython script which is supposed to hit a
>>web >>site and download a shapefile from that web site.
>>
>>The urllib module should do that for you but
>>
>>>I don't have any clue and would like your help.
>>
>>What do you know?
>>Do you understand HTML? and specifically how to create and read
>>img >tags?
>>
>>Do you know any Python? Do you know any other programming
>>language?
>>
>>>I use 9.x if this matter.
>>
>>Version 9.x of what?
>System - on a Mac perhaps?
>>If so it shouldn't matter since Python's urllib works K on the
>>older versions.
>>
>>We really need a liittle more background to help further.
>>
>>HTH,
>>
>>Alan G.
>>
>>
>
>
Tutor maillist - Tutor (AT) python (DOT) org
Tutor maillist - Tutor (AT) python (DOT) org