def grab_post_list(tags):
links = []
for x in range(0, 20):
resource = f'http://safebooru.org/index.php?page=dapi&s=post&q=index&tags={tags}&pid={x}'
async with aiohttp.ClientSession() as session:
async with session.get(resource) as data:
data = await data.read()
posts = html.fromstring(data)
for post in posts:
if 'file_url' in post.attrib:
file_url = post.attrib['file_url']
extention = file_url.split('.')[-1]
if extention in ['png', 'jpg', 'jpeg', 'gif']:
height = int(post.attrib['height'])
width = int(post.attrib['width'])
if width < 2000 and height < 2000:
links.append(post)
return links
评论列表
文章目录