登录功能不变, 增加分享
This commit is contained in:
7
const.py
7
const.py
@@ -21,9 +21,10 @@ ACCESS_KEY = '3QcjsqdCYCoy1khuDqia'
|
||||
SECRET_KEY = 'iPXte32y1deoySiDq0RwONUJIiIgvjTVhbfCL8tV'
|
||||
BUCKET = 'facebook'
|
||||
|
||||
# DOVE PROXY
|
||||
DOVE_USER = 'fetdog'
|
||||
DOVE_PWD = 'aAa123456aAa'
|
||||
# PROXY
|
||||
PROXY_HOST = 'http://proxy.ipipgo.com:31212'
|
||||
PROXY_USER = 'customer-94620c-country-US'
|
||||
PROXY_PASS = '4ea715cd'
|
||||
|
||||
|
||||
api_key = "adf0d1fc9c9313b7f87c18bf9caef01d"
|
||||
|
||||
5
main.py
5
main.py
@@ -10,7 +10,8 @@ TASK_TYPE = {
|
||||
'comment': playwright_comment,
|
||||
'like': playwright_like,
|
||||
'post': playwright_post,
|
||||
'login_account': playwright_m_login
|
||||
'login_account': playwright_m_login,
|
||||
'forward': playwright_share
|
||||
}
|
||||
|
||||
HOST = "http://118.193.40.152:8002"
|
||||
@@ -24,7 +25,7 @@ def get_task():
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
data = {
|
||||
"include_task_type": ["login_account", "get_account_profile"],
|
||||
"include_task_type": [],
|
||||
"exclude_task_type": []
|
||||
}
|
||||
response = requests.post(url, headers=header, json=data, proxies=None)
|
||||
|
||||
@@ -1382,7 +1382,6 @@ def playwright_m_login(username, password, code_2fa=None):
|
||||
page.wait_for_selector(f'{input_email}', timeout=60000).type(username, delay=30)
|
||||
time.sleep(1)
|
||||
page.wait_for_selector(f'//input[@id="m_login_password"]', timeout=60000).type(password, delay=30)
|
||||
time.sleep(1)
|
||||
page.click('div[aria-label="Log in"]')
|
||||
|
||||
success_login_selector1 = 'span:has-text("Check your notifications on another device")'
|
||||
@@ -1423,7 +1422,7 @@ def playwright_m_login(username, password, code_2fa=None):
|
||||
page.query_selector('div[role="button"][aria-label="Continue"]').click()
|
||||
|
||||
# 等待登录成功
|
||||
page.wait_for_selector('img[data-bloks-name="bk.components.Image"][src*=".fbcdn.net/v/t"]',timeout=60000)
|
||||
page.wait_for_selector('img[data-bloks-name="bk.components.Image"][src*=".fbcdn.net/v/t"]', timeout=60000)
|
||||
|
||||
# 成功
|
||||
logger.info(f"用户名:{username} 账号密码正确")
|
||||
@@ -1438,9 +1437,73 @@ def playwright_m_login(username, password, code_2fa=None):
|
||||
return {'cookies': json.dumps(c)}
|
||||
|
||||
|
||||
def playwright_share(cookies, target_url, content):
|
||||
path = os.path.join(BASE_PATH, 'chrome', '130-0008', 'chrome.exe')
|
||||
with lock:
|
||||
with sync_playwright() as playwright:
|
||||
update_windows_distinguish()
|
||||
browser = playwright.chromium.launch(
|
||||
headless=False, args=['--start-maximized'], executable_path=path
|
||||
)
|
||||
context = browser.new_context(no_viewport=True)
|
||||
context.add_cookies(parse_cookies(cookies))
|
||||
page = context.new_page()
|
||||
try:
|
||||
page.goto(target_url)
|
||||
check_account_status(page, cookies)
|
||||
if 'permalink.php?story_fbid' in target_url or '/posts/' in target_url:
|
||||
# 文字或图片类型
|
||||
share_button = '//div[@aria-label="Send this to friends or post it on your profile."]//span[@data-ad-rendering-role="share_button"]'
|
||||
input_box = '//form[@method="POST" and count(@*) = 1]/div/div/div[2]'
|
||||
share_now_button = '//span[text()="Share now"]'
|
||||
page.locator(share_button).last.click()
|
||||
elif 'watch/?v' in target_url or '/videos/' in target_url or 'watch?v' in target_url:
|
||||
# 视频类型, 视频类型,
|
||||
share_button = '//span[@dir="auto" and text()="Share"]'
|
||||
input_box = '//form[@method="POST" and count(@*) = 1]/div/div/div[2]'
|
||||
share_now_button = '//span[text()="Share now"]'
|
||||
page.locator(share_button).first.click()
|
||||
elif '/reel/' in target_url:
|
||||
# 短视频类型
|
||||
share_button = '//div[@aria-label="Share"]'
|
||||
input_box = '//form[@method="POST" and count(@*) = 1]/div/div/div[2]'
|
||||
share_now_button = '//span[text()="Share now"]'
|
||||
page.locator(share_button).click()
|
||||
else:
|
||||
raise OperationFailed(f'不支持的帖子类型: {target_url}')
|
||||
page.locator(input_box).type(content, delay=30)
|
||||
_edit_privacy(page)
|
||||
page.click(share_now_button)
|
||||
time.sleep(1)
|
||||
page.wait_for_selector('//span[text()="Posting..."]', state='detached')
|
||||
time.sleep(1)
|
||||
success_tag = page.query_selector('//span[text()="Shared to your profile"]')
|
||||
if not success_tag:
|
||||
raise OperationFailed('转发失败,原因未知')
|
||||
uid = cookies['c_user']
|
||||
page.goto(f'https://facebook.com/profile.php?id={uid}')
|
||||
page.wait_for_load_state()
|
||||
post_index = page.locator('//div[@aria-posinset="1"]//a[@role="link"]').nth(2)
|
||||
post_index.click()
|
||||
time.sleep(5)
|
||||
page.reload()
|
||||
post_url = page.url
|
||||
screenshot_content = _full_screenshot()
|
||||
except Error as e:
|
||||
raise OperationFailed(f'操作超时,请重试{e}')
|
||||
context.close()
|
||||
browser.close()
|
||||
|
||||
key = f'{uuid.uuid4()}.png'
|
||||
put_object(key, screenshot_content)
|
||||
return {'response_url': post_url, 'screenshot_key': key}
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# cookies = 'sb=mC6pxQuLvNLPTNpF-b9Tk8tK;c_user=61570961343759;xs=18:fBZ4XJkFA69uNg:2:1734940655:-1:-1;fr=0JjwzD0HEedbQSHGt.AWUHNQcfxnkbZ3j5rVd1NgTTGhA.BnaRfv..AAA.0.0.BnaRfv.AWWF3uukqmQ;datr=7xdpZzxiItbht8A5aCDBAhQU'
|
||||
# cookies = {"c_user":"61565823476070","datr":"q13hZowje6bbViFxECQpYyp8","fr":"01C6Lt4VArm5hELvx.AWXg75HOo-QNJgbiDl8qFtw_5lc.Bm4V2r..AAA.0.0.Bm4V25.AWWHzUeMTuI","m_pixel_ratio":"1.875","sb":"q13hZgJARsRIDmNJG8xUauAe","wd":"384x686","xs":"50%3A8luhgQ-Ea0vnhg%3A2%3A1726045627%3A-1%3A-1"}
|
||||
cookies = {"locale": "en_US", "datr": "rzU1aCVhVYJf3T71xejqTNsu", "sb": "rzU1aE50yid6sB8NmFpm0wrO", "m_pixel_ratio": "1", "wd": "1920x1080", "test_cookie": "CheckForPermission", "c_user": "61576241713602", "fr": "0b4H9Nzn9ewpMLvmN.AWdfhSSsJ8K9YtxX8KoCENM3G9PQKGS2FapTH7Zz09sZN3OOxuw.BoNTWv..AAA.0.0.BoNTW8.AWcfdsb7nN0O-4etI_bBIba3tMM", "xs": "33%3AYcBoxrBVIiv20w%3A2%3A1748317629%3A-1%3A-1"}
|
||||
# post(cookies, 'cs2025')
|
||||
# like(cookies, 'ZmVlZGJhY2s6MTIyMTA5NjE0NjU0NzkzNzc5')
|
||||
# comment(cookies, 'ZmVlZGJhY2s6MTIyMTA5NjE0NjU0NzkzNzc5', 'game la', 'xzpq.mp4')
|
||||
@@ -1456,7 +1519,7 @@ if __name__ == '__main__':
|
||||
# '2025-3-26~like',
|
||||
# # 'rg.jpg'
|
||||
# )
|
||||
# print(playwright_get_user_profile(cookies))
|
||||
print(playwright_get_user_profile(cookies))
|
||||
# playwright_set_user_profile(
|
||||
# cookies,
|
||||
# username='facebaby66'
|
||||
@@ -1476,4 +1539,4 @@ if __name__ == '__main__':
|
||||
# cookies = playwright_login('61575975148121', 'Mu1711rstu1999', 'JNCCTXB34EP5ME6RU6RND6SHBQ6KATAR')
|
||||
# # print(cookies)
|
||||
# pass
|
||||
cookies = playwright_m_login('61575975359852', 'siam05', 'IQDJG46PAIA4KENZRNPTSDO2BKGPQ2BS')
|
||||
# cookies = playwright_m_login('61575975359852', 'siam05', 'IQDJG46PAIA4KENZRNPTSDO2BKGPQ2BS')
|
||||
|
||||
Reference in New Issue
Block a user