Python and urllib

前端 未结 3 1060
感动是毒
感动是毒 2020-12-19 07:12

I\'m trying to download a zip file (\"tl_2008_01001_edges.zip\") from an ftp census site using urllib. What form is the zip file in when I get it and how do I save it?

3条回答
  •  执笔经年
    2020-12-19 08:04

    import os,urllib2
    out=os.path.join("/tmp","test.zip")
    url="ftp://ftp2.census.gov/geo/tiger/TIGER2008/01_ALABAMA/01001_Autauga_County/tl_2008_01001_edges.zip"
    page=urllib2.urlopen(url)
    open(out,"wb").write(page.read())
    

提交回复
热议问题