题图脚本

#!/usr/bin/python3 
# -*- coding: utf-8 -*-
"""
author: Tiebiao Zhang 2021/8/19 8:37
reviewer: 
"""
import re
import requests

if __name__ == '__main__':
url = "https://img.xjh.me/random_img.php"
rsp = requests.get(url)
str1 = rsp.content.decode('utf-8')
str1 = re.search(r'alt="(.*?)"', str1).group(0).split('"')[1]
url = "http:" + str1
rsp = requests.request('get', url)
content = rsp.content
with open('1.jpg', "wb") as f:
f.write(content) # 将内容写入图片
posted @ 2021-08-19 18:23  兔子春  阅读(28)  评论(0编辑  收藏  举报