下载png图标素材
- 作者: 那晚越女说我?
- 来源: 51数据库
- 2022-08-12
?
import re
import os
import urllib.request
home = "http://www.51sjk.com/Upload/Articles/1/0/320/320309_20220812153555571.com"
def downIco(tit, url):
page = urllib.request.urlopen(url).read()
page = page.decode("utf-8")
s_key = r'href="(http://demo.sc.chinaz.com.+?)"'
re_c = re.compile(s_key)
ls = re.findall(re_c, page)
i = 0
for l in ls:
i += 1
(path, file) = os.path.split(l)
print("(" + str(i) + "/" + str(len(ls)) + ") " + file)
if file.find('ico') > 0:
continue
if not os.path.exists(tit + "/" + file):
try:
urllib.request.urlretrieve(l, tit + "/" + file)
except:
print("Error!")
def getIndex(url):
page = ""
page = urllib.request.urlopen(url).read()
page = page.decode("utf-8")
s_key = r'\<p\>\<a(.+?)\</p\>'
re_c = re.compile(s_key)
ls = re.findall(re_c, page)
i = 0
for l in ls:
i += 1
s1 = l.split('"')
url = s1[3]
tit = s1[5]
img = s1[7]
tit = tit.replace("图标", "").replace("下载", "")
print("(" + str(i) + "/" + str(len(ls)) + ") " + url + ", " + tit + ", " + img)
if not os.path.exists(tit):
os.makedirs(tit)
(path, file) = os.path.split(img)
if not os.path.exists(tit + "/" + file):
try:
urllib.request.urlretrieve(img, tit + "/" + file)
except:
print("Error!")
downIco(tit, home + url)
if __name__ == "__main__":
tubiao = "/tubiao/"
url = home + tubiao
getIndex(url)
for i in range(2, 10):
url = home + tubiao + "index_" + str(i) + ".html"
getIndex(url)
推荐阅读
热点文章
Discord.py(重写)on_member_update 无法正常工作
0
Discord.py 在 vc 中获取用户分钟数
0
discord.py 重写 |为我的命令出错
0
Discord.py rewrite 如何 DM 命令?
0
播放音频时,最后一部分被切断.如何解决这个问题?(discord.py)
0
在消息删除消息 Discord.py
0
如何使 discord.py 机器人私人/直接消息不是作者的人?
0
(Discord.py) 如何获取整个嵌入内容?
0
Discord bot 尽管获得了许可,但不能提及所有人
0
Discord.py discord.NotFound 异常
0
