Files
py_facebook/test_playwright_share.py
work b0f854ebdb
All checks were successful
Update Code / StopService (windows-101.36.104.175) (push) Successful in 0s
Update Code / StopService (windows-101.36.102.136) (push) Successful in 0s
Update Code / CD (windows-101.36.102.136) (push) Successful in 8s
Update Code / CD (windows-101.36.104.175) (push) Successful in 12s
修复转发
2026-04-10 22:42:01 +08:00

44 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import json
from loguru import logger
import spider.task as task_module
# 直接在这里填写测试参数
COOKIES = {"c_user":"61588333773832","datr":"HE2Wad2MttKeo5sq6N0H-Nzm","fr":"0EmS028gNHuZANcda.AWfAv-SGO_JSJHlIuvtEdOZckpo2Dpo2s5AFnk3pHsYvmEFUMRU.Bplk3I..AAA.0.0.Bplk3I.AWePI6kwlSPrrSIFkRyEX3BGU6Y","xs":"21:m9VOT0BnaXqORA:2:1771457996:-1:-1"}
TARGET_URL = "https://www.facebook.com/permalink.php?story_fbid=pfbid023QsxMBw26HAdt3LW1Ln7GUugWYbQkzfL9Ws68XUiuaXJvFD3u1iKtVFq7hpypdFtl&id=61580561183111"
CONTENT = "Youve earned my admiration with this quality."
def _validate_config():
missing = [key for key, value in COOKIES.items() if not str(value).strip()]
if missing:
raise ValueError(f"cookies 缺少字段: {', '.join(missing)}")
if not TARGET_URL.strip():
raise ValueError("TARGET_URL 不能为空")
if "facebook.com" not in TARGET_URL:
raise ValueError(f"TARGET_URL 不是有效的 Facebook 链接: {TARGET_URL}")
def main():
_validate_config()
logger.add("./log/test_playwright_share.log", rotation="20 MB")
result = task_module.playwright_share(
cookies=COOKIES,
target_url=TARGET_URL,
content=CONTENT,
)
logger.info("转发结果: {}", result)
print(json.dumps(result, ensure_ascii=False, indent=2))
if __name__ == "__main__":
main()