说明:
功能:某平台通过识别算法技术把工程机械进行识别(如:挖掘机、塔吊、安全帽、吊车等),然后通过地址下载原图和识别后的图片分别放在本地文件夹(yuantu 和 shibiehou文件夹);
代码如下:
import requests
url="https://XXXXXXX.com/gv-crcs-op/prod/picture/0045003a-30305110-37323537/PNaq0m20220924091026alarm.jpg"
url2 =url.replace('alarm','') #把识别后地址"alarm"去掉,就是原图url
headers={
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36'
}
for i in(url,url2):
r = requests.get(i, headers=headers)
#识别后
if i==url:
f = open("shibiehou/108.jpg", "wb")
f.write(r.content)
f.close()
#原图
else:
i==url2
f = open("yuantu/108.jpg", "wb")
f.write(r.content)
f.close()
![](/i/l/?n=22&i=blog/1193459/202210/1193459-20221024095914865-463956051.png)
标签:原图,URL,jpg,url,地址,文件夹,url2,识别 From: https://www.cnblogs.com/suhongzhen/p/16820576.html