乘胜追击
Posted zqxqx
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了乘胜追击相关的知识,希望对你有一定的参考价值。
目标:汽车之家https://car.autohome.com.cn/pic/series/153-1-p5.html
#!/urs/bin/evn python # -*- coding:utf-8 -*- import requests import re def get_url(url): response = requests.get(url) response.encoding = "gb2312" r = ‘<img src="(.*?)" alt=".*?">‘ url_list = re.findall(r, response.text) return url_list def get_jpg(url, name): response = requests.get(url) response.encoding = "gb2312" with open(r"D:data\\%d.jpg" % name, "wb") as ft: ft.write(response.content) if __name__ == ‘__main__‘: a = 1 for i in range(1, 6): url_list = get_url("https://car.autohome.com.cn/pic/series/153-1-p%d.html" % i) for url in url_list: com_url = "http:" + url get_jpg(com_url, a) a += 1
以上是关于乘胜追击的主要内容,如果未能解决你的问题,请参考以下文章