feat(crawler): 修改嘟文格式

修改嘟文格式

Signed-off-by: Ching <loooching@gmail.com>
This commit is contained in:
Ching 2023-07-17 14:34:03 +08:00
parent 129df366ed
commit c0533a4772

View File

@ -127,18 +127,19 @@ def toot():
if redis_db.sismember('send-chh-article-id', article['article_id']):
continue
# download article image to a temp file
img = requests.get(article['img_url'])
# upload article image to mastodon
media = mastodon_client.media_post(article['img_url'])
media = mastodon_client.media_post(img.content, 'image/jpeg')
# toot the article info
toot_content = """{title} - {category} by {author} \n
{content} \n
{url}""".format(title=article['title'],
category=article['category'],
author=article['author'],
content=article['content'],
url=article['url'])
toot_content = """{title} - #{category} by {author} \n {content} \n\n {url} \n\n #chh #chiphell \n """.format(
title=article['title'],
category=article['category'],
author=article['author'],
content=article['content'],
url=article['url'])
mastodon_client.toot(toot_content, media_ids=[media['id']])
mastodon_client.status_post(toot_content, media_ids=[media['id']])
# add the article['id'] to the set
redis_db.sadd('send-chh-article-id', article['article_id'])
@ -147,3 +148,4 @@ def toot():
if __name__ == '__main__':
crawler()
toot()
requests.get('https://up.tunpok.com/api/push/yoLZhc0rZR?status=up&msg=OK&ping=')