利用 urlretrieve 获取远程文件保存到本地
from urllib.request import urlretrieveurlretrieve(‘http://www.python.org‘,r‘D:\python\python37\python_wegpage.html‘)
利用 urlopen 和 re 匹配获取远程文件中的数据
from urllib.request import urlopenimport rewegpage = urlopen(‘http://www.python.org‘)text = wegpage.read()text = text.decode(‘utf-8‘)m = re.search(‘<a href="([^"]+)" .*?>about</a>‘,text,re.IGNORECASE)m.group(1)
使用 urllib 打开、匹配和保存远程文件
原文地址:https://www.cnblogs.com/swingingmace/p/8395004.html