Aid = re.compile(r'"authorId":"(\d+?)"') Ana = re.compile(r'"userName":"(.+?)"') defId2U(Id): #html = etree.HTML(getHtml(Id).text) text = getHtml(Id).text st = text.find(f'{Id}_p0.jpg') if st == -1: st = text.find(f'{Id}_p0.png') if st == -1: print(text) text = text[st:st+500] ## print(text) ## print(Aid.findall(text)) authorId = Aid.findall(text)[0] userName = Ana.findall(text)[0] returnf'<a href="https://www.pixiv.net/users/{authorId}" target="_blank" rel="nofollow">{userName}</a>'
Us = (Id2U(N2Id(name)) for name in os.listdir(r'./gallary'))