更改账户信息功能直接进入链接(点击可能会操作失败),
This commit is contained in:
@@ -19,10 +19,14 @@ from loguru import logger
|
||||
from playwright._impl._page import Page
|
||||
from playwright.sync_api import sync_playwright, Error, TimeoutError
|
||||
|
||||
import const
|
||||
from const import BUCKET, BASE_PATH
|
||||
from exceptions import AuthException, OperationFailed
|
||||
from miniofile import client, put_object
|
||||
|
||||
# 登录, 检查账号, 获取账号配置, 更新账号配置是否隐藏浏览器
|
||||
HEADLESS = True
|
||||
|
||||
|
||||
def sleep(a, b=None):
|
||||
if not b:
|
||||
@@ -423,7 +427,7 @@ def playwright_get_user_profile(cookies, username=None):
|
||||
with sync_playwright() as playwright:
|
||||
update_windows_distinguish()
|
||||
browser = playwright.chromium.launch(
|
||||
headless=True, args=['--start-maximized'], executable_path=path
|
||||
headless=HEADLESS, args=['--start-maximized'], executable_path=path
|
||||
)
|
||||
context = browser.new_context(no_viewport=True)
|
||||
context.add_cookies(parse_cookies(cookies))
|
||||
@@ -474,16 +478,18 @@ def playwright_set_user_profile(cookies, username=None, first_name=None, last_na
|
||||
with sync_playwright() as playwright:
|
||||
update_windows_distinguish()
|
||||
browser = playwright.chromium.launch(
|
||||
headless=True, args=['--start-maximized'], executable_path=path
|
||||
headless=HEADLESS, args=['--start-maximized'], executable_path=path
|
||||
)
|
||||
context = browser.new_context(no_viewport=True)
|
||||
context.add_cookies(parse_cookies(cookies))
|
||||
page = context.new_page()
|
||||
check_account_status(page, parse_cookies(cookies))
|
||||
try:
|
||||
url = 'https://accountscenter.facebook.com/?entry_point=app_settings'
|
||||
cookies_dict = {i['name']: i['value'] for i in parse_cookies(cookies)}
|
||||
uid = cookies_dict["c_user"]
|
||||
|
||||
url = f'https://accountscenter.facebook.com/profiles/{uid}'
|
||||
retry_goto(page, url)
|
||||
page.locator('//div[@role="list"]/div').first.click()
|
||||
|
||||
if first_name or last_name:
|
||||
if first_name and last_name:
|
||||
@@ -528,7 +534,7 @@ def playwright_check_account_cookies(cookies):
|
||||
with sync_playwright() as playwright:
|
||||
update_windows_distinguish()
|
||||
browser = playwright.chromium.launch(
|
||||
headless=True, args=['--start-maximized'], executable_path=path
|
||||
headless=HEADLESS, args=['--start-maximized'], executable_path=path
|
||||
)
|
||||
context = browser.new_context(no_viewport=True)
|
||||
context.add_cookies(parse_cookies(cookies))
|
||||
@@ -602,7 +608,7 @@ def playwright_login(username, password, code_2fa=None):
|
||||
with sync_playwright() as playwright:
|
||||
update_windows_distinguish()
|
||||
browser = playwright.chromium.launch(
|
||||
headless=False, args=['--start-maximized'], executable_path=path
|
||||
headless=HEADLESS, args=['--start-maximized'], executable_path=path
|
||||
)
|
||||
random_user_agent = UserAgent().getBrowser("Chrome").get("useragent")
|
||||
logger.info(f"使用ua={random_user_agent}")
|
||||
@@ -716,7 +722,7 @@ def playwright_m_login(username, password, code_2fa=None):
|
||||
with sync_playwright() as playwright:
|
||||
update_windows_distinguish()
|
||||
browser = playwright.chromium.launch(
|
||||
headless=True, args=['--start-maximized'], executable_path=path
|
||||
headless=HEADLESS, args=['--start-maximized'], executable_path=path
|
||||
)
|
||||
# random_user_agent = UserAgent().getBrowser(["Chrome Mobile iOS"]).get("useragent")
|
||||
random_user_agent = "Mozilla/5.0 (Linux; Android 12; Pixel 6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.41 Mobile Safari/537.36"
|
||||
@@ -909,7 +915,7 @@ if __name__ == '__main__':
|
||||
# cookies = '{"datr": "mm0taNtaPfOxWhpxdzpkVjV0", "sb": "mm0taFuFnO_L1FpzkKDiA4lw", "wd": "1920x953", "locale": "en_US", "c_user": "61575901481649", "fr": "0c0y2KyMv8lRJ6NNq.AWe7DLt-TSkoOyn3DhRjhA4ByOITAhfSwaiIw4eQE5ilq4Q4KAY.BoLW2a..AAA.0.0.BoLW3M.AWfHVOhZIAGgDh_3BvPFPi8-YhE", "xs": "29%3ASM0qc4U4Ile_MA%3A2%3A1747807693%3A-1%3A-1", "presence": "C%7B%22t3%22%3A%5B%5D%2C%22utc3%22%3A1747807698911%2C%22v%22%3A1%7D"}'
|
||||
cookies = '{"locale": "en_US", "datr": "PaB4aGZCgstQYUkBHpEVnEe8", "sb": "PaB4aAgR68sRQtATM6v7gEu5", "m_pixel_ratio": "1", "wd": "1920x1080", "test_cookie": "CheckForPermission", "c_user": "100094571602733", "fr": "0g0qqVhuLyyrKSaUv.AWdif7wExy29FD7aMjwFvrQFqoBzz-S7Qbeg8la4QMVeGv43eLg.BoeKA9..AAA.0.0.BoeKBQ.AWdj3k5XKtwF766wY3n-cro4yw8", "xs": "15%3A52m6IVmYaMzM3Q%3A2%3A1752735825%3A-1%3A-1"}'
|
||||
# print(playwright_share(cookies, "https://www.facebook.com/groups/1702958116839437/permalink/2210833932718517/", ""))
|
||||
# print(playwright_get_user_profile(cookies))
|
||||
print(playwright_get_user_profile(cookies))
|
||||
# # 永久链接的帖子点赞
|
||||
# print(playwright_like(cookies, "https://www.facebook.com/groups/1070754870427928/permalink/1873461830157224/"))
|
||||
#
|
||||
@@ -972,8 +978,3 @@ if __name__ == '__main__':
|
||||
# 评论
|
||||
# print(playwright_comment(cookies, "https://www.facebook.com/groups/7423373454348259/permalink/24322822973976709/",
|
||||
# "6"))
|
||||
|
||||
# 转发
|
||||
print(playwright_share(cookies,
|
||||
"https://www.facebook.com/permalink.php?story_fbid=pfbid0xsKBsFVR8qGyRnWPUBkyHyk5tnCTtweaUm59HskuNxqwryw3dPYfbRTmTRt4CoEsl&id=61556406998616",
|
||||
"也太少了吧"))
|
||||
|
||||
Reference in New Issue
Block a user