我正在编写一个小型 python 脚本,以自动将每日帖子发布到我妻子管理的页面上。它会下载图片,与标题合并,然后使用 URL 和一些文本发布到页面。我的想法最终是将其放在我拥有的 Linux 机器上并安排它每天触发一次。如果我确实要使其自动化,我想知道是否有办法检查并确保帖子尚未完成。文本是一致的(并且是唯一的,因为其中有日期)。有没有办法让脚本在发布之前在页面中搜索文本?到目前为止的搜索还没有取得太多成果。
根据您要求的方法,根据另一篇文章的讨论,如果不是 Facebook 合作伙伴,似乎无法对用户的帖子和特定搜索文本进行查询。
建议:
如果您的自动化脚本是单个实例并且是唯一发布帖子的实例,那么在您的脚本本地更新和管理的简单历史记录就足够了吗?
#Pseudo code
# Obviously, it would make sense to make this history data structure
# persistent across runs of your script
published_posts = set()
def publish_post(text: str):
if text in published_posts:
console.log("Post already previously published!")
return
resp = api.post(text)
if resp.status != 200:
console.log("Post unsuccessful!")
raise Exception(resp.status)
published_posts.add(text)