zoukankan      html  css  js  c++  java
  • python简单小爬虫爬取易车网图片

    上代码:

     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')
  • 相关阅读:
    Javascript基础知识4
    JavaScript基础知识3
    JavaScript基本知识2
    JavaScript基本知识1
    BFC?来自CSS中的BFC
    创建【哆啦A梦】风格字体
    理解JavaScript函数
    我所了解的BFC
    jQuery
    html
  • 原文地址:https://www.cnblogs.com/pythonal/p/6027173.html
Copyright © 2011-2022 走看看