feat(crawler): 修改嘟文格式
修改嘟文格式 Signed-off-by: Ching <loooching@gmail.com>
This commit is contained in:
parent
129df366ed
commit
c0533a4772
12
crawler.py
12
crawler.py
@ -127,18 +127,19 @@ def toot():
|
|||||||
if redis_db.sismember('send-chh-article-id', article['article_id']):
|
if redis_db.sismember('send-chh-article-id', article['article_id']):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# download article image to a temp file
|
||||||
|
img = requests.get(article['img_url'])
|
||||||
# upload article image to mastodon
|
# 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 the article info
|
||||||
toot_content = """{title} - {category} by {author} \n
|
toot_content = """{title} - #{category} by {author} \n {content} \n\n {url} \n\n #chh #chiphell \n """.format(
|
||||||
{content} \n
|
title=article['title'],
|
||||||
{url}""".format(title=article['title'],
|
|
||||||
category=article['category'],
|
category=article['category'],
|
||||||
author=article['author'],
|
author=article['author'],
|
||||||
content=article['content'],
|
content=article['content'],
|
||||||
url=article['url'])
|
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
|
# add the article['id'] to the set
|
||||||
redis_db.sadd('send-chh-article-id', article['article_id'])
|
redis_db.sadd('send-chh-article-id', article['article_id'])
|
||||||
@ -147,3 +148,4 @@ def toot():
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
crawler()
|
crawler()
|
||||||
toot()
|
toot()
|
||||||
|
requests.get('https://up.tunpok.com/api/push/yoLZhc0rZR?status=up&msg=OK&ping=')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user