[Tutor] Please help!!
Kent Johnson
kent37 at tds.net
Sun May 21 15:27:53 CEST 2006
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:
http://www.voidspace.org.uk/python/articles/urllib2.shtml
Kent
>
> Thank you for your assistance. I'm glad you're up there to assist.
>
> Matt
>
>
>
>
>
> ------------------------------------------------------------------------
> From: /"Alan Gauld" <alan.gauld at freenet.co.uk>/
> To: /"MATATA EMMANUEL" <emmatata at hotmail.com>/
> CC: /<tutor at python.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.
> >
> >OK, 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.
> >
> >http://www.crummy.com/software/BeautifulSoup/
> >
> >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
> >http://www.freenetpages.co.uk/hp/alan.gauld
> >
> >>
> >> From: "Alan Gauld" <alan.gauld at freenet.co.uk>
> >> To: "MATATA EMMANUEL" <emmatata at hotmail.com>,<Tutor at python.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?
> >> >Operating System - on a Mac perhaps?
> >> >If so it shouldn't matter since Python's urllib works OK on the
> >> >older versions.
> >> >
> >> >We really need a liittle more background to help further.
> >> >
> >> >HTH,
> >> >
> >> >Alan G.
> >> >
> >>
> >
> >
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list