上代码:

 1 import requests,urllib.request
 2 from bs4 import BeautifulSoup
 3 url = 'http://photo.bitauto.com/'
 4 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'}
 5 source_code = requests.get(url,headers = header)
 6 # print (source_code)
 7 plain_text = source_code.text
 8 # print (plain_text)
 9 Soup = BeautifulSoup(plain_text)
10 # print (Soup)
11 download_link = []
12 folder_path = 'F:/pictures_py/cars/'
13 for pic_tag in Soup.find_all('img'):
14     pic_link = pic_tag.get('src')
15     download_link.append(pic_link)
16 # print (download_link)
17 for item in download_link:
18     urllib.request.urlretrieve(item,folder_path + item[-10:])
19     print ('done')

 

相关文章:

  • 2021-10-17
  • 2021-10-04
  • 2022-12-23
  • 2021-05-26
  • 2022-12-23
  • 2021-04-11
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-31
  • 2021-11-19
  • 2022-01-29
  • 2021-12-10
  • 2021-09-07
  • 2021-07-02
  • 2022-02-04
相关资源
相似解决方案