python下載文件demo

from urllib.request import urlretrieve
from urllib.request import urlopen
from bs4 import BeautifulSouphtml

#下載文件demopython

html = urlopen("http://www.pythonscraping.com")
bsObj = BeautifulSoup(html,"html.parser")
imageLocation = bsObj.find("a",{"id":"logo"}).find("img")["src"]
urlretrieve(imageLocation,"logo.jpg")api

相關文章
相關標籤/搜索