python爬取动态图片(gif)

Posted cherish__lin

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python爬取动态图片(gif)相关的知识,希望对你有一定的参考价值。

 

一、给定url,直接下载到本地

技术图片
import re
import requests
from bs4 import BeautifulSoup


def get_gif(url, a):
    response = requests.get(url)
    # 自己电脑上的文件夹路径,默认命名 a.gif
    with open("C:\Users\acm\Desktop\新建文件夹\%d.gif" % a, wb) as file:
        file.write(response.content)


if __name__ == __main__:
    # url 获取动态图片地址
    url = http://game.gtimg.cn/images/nz/cp/a20201117decbeta/m1-prop1.gif
    get_gif(url, 1)
View Code

 

以上是关于python爬取动态图片(gif)的主要内容,如果未能解决你的问题,请参考以下文章