使用python爬取一張圖片
from urllib.request import urlretrieve
from urllib.request import urlopen
from bs4 import BeautifulSoup
html = urlopen("http://www.pythonscraping.com")
bsObj = BeautifulSoup(html)
imageLocation = bsObj.find("a", {"id": "logo"}).find("img")["src"]
urlretrieve (imageLocation, "/Users/phoenix/Downloads/logo.jpg")
urlretrieve裏第二個參數是路徑和名稱。