#-------------------------------------------------------------------------------
# Name: urllib 模块
# Purpose:
#
# Author: quan
#
# Created: 15/08/2013
# Copyright: (c) quan 2013
# Licence: <your licence>
#-------------------------------------------------------------------------------
import urllib
#
str1 = """<a class="postroll" title="Download Windows 64-bit" href="http://downloads.mongodb.org/win32/mongodb-win32-x86_64-2.4.5.zip" data-postroll="/dr/downloads.mongodb.org/win32/mongodb-win32-x86_64-2.4.5.zip/download"> 64-bit </a>"""
#查找到网页中的带有title的标签
title = str1.find(r'title=')
print title
#表示从title向后面查找
href = str1.find(r'href=',title)
print href
#表示从href向后面查找
html = str1.find(r'.zip',href)
print html
#整合url要读取文章的路径
url = str1[href + 6:html+4]
print url
urllib.urlretrieve(url,'D:\\mongodb-win32-x86_64-2.4.5.zip')
python中urllib下载软件包
最新推荐文章于 2024-04-28 15:36:00 发布