存储数据
1、python3+版本中,使用urllib.request.urlretrieve下载文件
#下载一个文件,并且知道如何获取它以及它的文件类型,以下是下载一个文件 from urllib.request import urlretrieve from urllib.request import urlopen from bs4 import BeautifulSoup html = urlopen("http://www.pythonscraping.com") bs = BeautifulSoup(html) imagelocation = bs.find("a",{"id":"logo"}).find("img")["src"] urlretrieve(imagelocation,"logo.jpg") #以上会在程序运行的文件夹里下载一个名为“logo.jpg”的图片
2
浙公网安备 33010602011771号