1. if __name__ == "__main__":
    2. # 如何爬取图片数据
    3. url = 'https://pic.qiushibaike.com/system/pictures/12172/121721055/medium/9OSVY4ZSU4NN6T7V.jpg'
    4. # content返回的是二进制形式的图片数据
    5. # text(字符串) content(二进制)json() (对象)
    6. img_data = requests.get(url=url).content
    7. with open('./qiutu.jpg', 'wb') as fp:
    8. fp.write(img_data)