上代码:
import requests,urllib.request
from bs4 import BeautifulSoup
url = 'http://photo.bitauto.com/'
header = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 UBrowser/5.7.16173.12 Safari/537.36'}
source_code = requests.get(url,headers = header)
# print (source_code)
plain_text = source_code.text
# print (plain_text)
Soup = BeautifulSoup(plain_text)
# print (Soup)
download_link = []
folder_path = 'F:/pictures_py/cars/'
for pic_tag in Soup.find_all('img'):
pic_link = pic_tag.get('src')
download_link.append(pic_link)
# print (download_link)
for item in download_link:
urllib.request.urlretrieve(item,folder_path + item[-10:])
print ('done')