转发灰度页面也能正常执行
All checks were successful
Update Code / StopService (windows-101.36.102.136) (push) Successful in 1s
Update Code / StopService (windows-101.36.104.175) (push) Successful in 1s
Update Code / CD (windows-101.36.102.136) (push) Successful in 11s
Update Code / CD (windows-101.36.104.175) (push) Successful in 25s
All checks were successful
Update Code / StopService (windows-101.36.102.136) (push) Successful in 1s
Update Code / StopService (windows-101.36.104.175) (push) Successful in 1s
Update Code / CD (windows-101.36.102.136) (push) Successful in 11s
Update Code / CD (windows-101.36.104.175) (push) Successful in 25s
This commit is contained in:
@@ -319,6 +319,7 @@ def is_post_liked_in_dialog(page):
|
||||
print("未找到点赞按钮")
|
||||
return False
|
||||
|
||||
|
||||
def playwright_like(cookies, target_url):
|
||||
path = os.path.join(BASE_PATH, 'chrome', '130-0008', 'chrome.exe')
|
||||
with lock:
|
||||
@@ -614,9 +615,9 @@ def _is_facebook_home(page):
|
||||
def _get_share_config(target_url):
|
||||
if 'permalink.php?story_fbid' in target_url or '/posts/' in target_url or '/permalink/' in target_url:
|
||||
return {
|
||||
'share_button': '//*[@role="dialog"]//div[@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"]',
|
||||
'share_button': '//*[@role="dialog"]//div[@aria-label="Send this to friends or post it on your profile."]',
|
||||
'input_box': "//div[contains(@aria-placeholder, \"What's on your mind\")] | //div[contains(@aria-placeholder, \"Say something about this\")]",
|
||||
'share_now_button': '//*[@role="dialog"]//div[@role="button" and @aria-label="Share now"] | //*[@role="dialog"]//div[@aria-label="Share"]',
|
||||
}
|
||||
if 'watch/?v' in target_url or '/videos/' in target_url or 'watch?v' in target_url:
|
||||
return {
|
||||
@@ -635,37 +636,23 @@ def _get_share_config(target_url):
|
||||
|
||||
def _click_share_button(page, selector):
|
||||
locator = page.locator(selector)
|
||||
deadline = time.time() + 120
|
||||
|
||||
while time.time() < deadline:
|
||||
locator.wait_for()
|
||||
count = locator.count()
|
||||
|
||||
for index in range(count):
|
||||
candidate = locator.nth(index)
|
||||
try:
|
||||
if candidate.is_visible():
|
||||
candidate.scroll_into_view_if_needed(timeout=30000)
|
||||
candidate.click(timeout=60000)
|
||||
if not candidate.is_visible():
|
||||
continue
|
||||
candidate.click(timeout=3000, trial=True)
|
||||
candidate.click(timeout=5000)
|
||||
page.wait_for_timeout(1000)
|
||||
|
||||
return
|
||||
except Error:
|
||||
continue
|
||||
page.wait_for_timeout(1000)
|
||||
|
||||
element = page.query_selector(selector)
|
||||
if element is None:
|
||||
raise OperationFailed(f'未找到分享按钮: {selector}')
|
||||
|
||||
page.evaluate(
|
||||
"""(node) => {
|
||||
const clickable =
|
||||
node.closest('[role="button"]') ||
|
||||
node.closest('[aria-label]') ||
|
||||
node.parentElement ||
|
||||
node;
|
||||
clickable.click();
|
||||
}""",
|
||||
element
|
||||
)
|
||||
page.wait_for_timeout(1000)
|
||||
raise OperationFailed(f'未找到可点击的分享按钮: {selector}')
|
||||
|
||||
|
||||
def _fill_share_content(page, selector, content):
|
||||
@@ -726,9 +713,7 @@ def _submit_share(page, selector):
|
||||
share_now_button = page.locator(selector).first
|
||||
share_now_button.wait_for(state='visible', timeout=60000)
|
||||
share_now_button.click(timeout=60000)
|
||||
page.wait_for_selector('//span[text()="Posting..."]', state='detached', timeout=180000)
|
||||
page.wait_for_selector('//span[text()="Shared to your profile"]', timeout=180000)
|
||||
|
||||
page.wait_for_timeout(15000)
|
||||
|
||||
def playwright_post(cookies, content, image_key=None, dry_run=False):
|
||||
path = os.path.join(BASE_PATH, 'chrome', '130-0008', 'chrome.exe')
|
||||
@@ -768,7 +753,9 @@ def playwright_post(cookies, content, image_key=None, dry_run=False):
|
||||
if image_key:
|
||||
file_path = _download_post_media(image_key)
|
||||
sleep(1, 2)
|
||||
page.locator('input[accept="image/*,image/heif,image/heic,video/*,video/mp4,video/x-m4v,video/x-matroska,.mkv"]').set_input_files(file_path)
|
||||
page.locator(
|
||||
'input[accept="image/*,image/heif,image/heic,video/*,video/mp4,video/x-m4v,video/x-matroska,.mkv"]').set_input_files(
|
||||
file_path)
|
||||
page.locator('//div[contains(@aria-placeholder, "What\'s on your mind")]').first.wait_for(
|
||||
state='visible', timeout=300000
|
||||
)
|
||||
@@ -1489,6 +1476,37 @@ def playwright_share(cookies, target_url, content):
|
||||
retry_goto(page, target_url)
|
||||
share_config = _get_share_config(target_url)
|
||||
_click_share_button(page, share_config['share_button'])
|
||||
if 'permalink.php?story_fbid' in target_url or '/posts/' in target_url or '/permalink/' in target_url:
|
||||
if page.query_selector(
|
||||
'//*[@role="dialog"]//h2/span[text()="Share"]') is None:
|
||||
if page.query_selector('//*[@role="dialog" and @aria-label="Share options"]'):
|
||||
page.query_selector(
|
||||
'//*[@role="dialog" and @aria-label="Share options"]//span[text()="Share to Feed"]').click()
|
||||
# 判断是否有弹窗
|
||||
if page.query_selector('//*[@role="dialog"]//span[@id="_R_imjbsmj5ilipam_"]'):
|
||||
try:
|
||||
# 点击返回
|
||||
page.wait_for_selector(
|
||||
'//*[@role="dialog"]//div[@aria-label="Continue"]',
|
||||
state='visible',
|
||||
timeout=5000
|
||||
)
|
||||
continue_btn = page.query_selector('//*[@role="dialog"]//div[@aria-label="Continue"]')
|
||||
if continue_btn is not None:
|
||||
continue_btn.click()
|
||||
|
||||
# 点击Done
|
||||
page.wait_for_selector(
|
||||
'//*[@role="dialog"]//div[@aria-label="Done with privacy audience selection and close dialog"]',
|
||||
state='visible',
|
||||
timeout=5000
|
||||
)
|
||||
done_btn = page.query_selector('//*[@role="dialog"]//div[@aria-label="Done with privacy audience selection and close dialog"]')
|
||||
if done_btn is not None:
|
||||
done_btn.click()
|
||||
except TimeoutError:
|
||||
pass
|
||||
|
||||
_fill_share_content(page, share_config['input_box'], content)
|
||||
_edit_privacy(page)
|
||||
_submit_share(page, share_config['share_now_button'])
|
||||
@@ -1539,7 +1557,13 @@ def playwright_share(cookies, target_url, content):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
cookies = {"c_user":"61585626484995","datr":"NGBPadlTOQH5fwTPcUTGtLI5","dpr":"0.3400000035762787","fr":"0OHgdNICbgL23ZzCq..BptI5c..AAA.0.0.BptI5l.AWf9nkRp50sAbeHCdwhX--SsOVA","m_pixel_ratio":"0.3400000035762787","ps_l":"1","ps_n":"1","sb":"-Y-0adE6TkW7Fd070vzZxn5H","useragent":"TW96aWxsYS81LjAgKExpbnV4OyBBbmRyb2lkIDEwOyBGaW5kIFg1IFBybyBCdWlsZC9UUDFBLjIyMTAwNS4wMDI7IHd2KSBBcHBsZVdlYktpdC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBWZXJzaW9uLzQuMCBDaHJvbWUvMTI3LjAuMC4wIE1vYmlsZSBTYWZhcmkvNTM3LjM2IFtGQkFOL0VNQTtGQkxDL2VuX1VTO0ZCQVYvNDE5LjAuMC4xMC4xMjA7XQ%3D%3D","wd":"500x402","x-referer":"eyJyIjoiL3NlY3VyaXR5LzJmYWMvc2V0dXAvcXJjb2RlL2dlbmVyYXRlLz9leHQ9MTc3MzcwMDE2NiZoYXNoPUFlY2Vld0J0M0Q3UnhaMDgwTVBYMHR0UDFKUSIsImgiOiIvc2VjdXJpdHkvMmZhYy9zZXR1cC9xcmNvZGUvZ2VuZXJhdGUvP2V4dD0xNzczNzAwMTY2Jmhhc2g9QWVjZWV3QnQzRDdSeFowODBNUFgwdHRQMUpRIiwicyI6Im0ifQ%3D%3D","xs":"42:KzK0Y_fjLkJzUQ:2:1766809815:-1:-1"}
|
||||
cookies = {"c_user": "61585626484995", "datr": "NGBPadlTOQH5fwTPcUTGtLI5", "dpr": "0.3400000035762787",
|
||||
"fr": "0OHgdNICbgL23ZzCq..BptI5c..AAA.0.0.BptI5l.AWf9nkRp50sAbeHCdwhX--SsOVA",
|
||||
"m_pixel_ratio": "0.3400000035762787", "ps_l": "1", "ps_n": "1", "sb": "-Y-0adE6TkW7Fd070vzZxn5H",
|
||||
"useragent": "TW96aWxsYS81LjAgKExpbnV4OyBBbmRyb2lkIDEwOyBGaW5kIFg1IFBybyBCdWlsZC9UUDFBLjIyMTAwNS4wMDI7IHd2KSBBcHBsZVdlYktpdC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBWZXJzaW9uLzQuMCBDaHJvbWUvMTI3LjAuMC4wIE1vYmlsZSBTYWZhcmkvNTM3LjM2IFtGQkFOL0VNQTtGQkxDL2VuX1VTO0ZCQVYvNDE5LjAuMC4xMC4xMjA7XQ%3D%3D",
|
||||
"wd": "500x402",
|
||||
"x-referer": "eyJyIjoiL3NlY3VyaXR5LzJmYWMvc2V0dXAvcXJjb2RlL2dlbmVyYXRlLz9leHQ9MTc3MzcwMDE2NiZoYXNoPUFlY2Vld0J0M0Q3UnhaMDgwTVBYMHR0UDFKUSIsImgiOiIvc2VjdXJpdHkvMmZhYy9zZXR1cC9xcmNvZGUvZ2VuZXJhdGUvP2V4dD0xNzczNzAwMTY2Jmhhc2g9QWVjZWV3QnQzRDdSeFowODBNUFgwdHRQMUpRIiwicyI6Im0ifQ%3D%3D",
|
||||
"xs": "42:KzK0Y_fjLkJzUQ:2:1766809815:-1:-1"}
|
||||
# print(playwright_check_account_cookies(cookies))
|
||||
# print(playwright_set_user_profile(cookies, "61584735094876", "Inaaya", "Inaaya",
|
||||
# "facebook/user_upload/0196f098-851c-7810-b2aa-0833a0a7b09d/8c428558-2d90-4f45-baa3-a25f8a654b5c.png"))
|
||||
|
||||
@@ -6,9 +6,15 @@ 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"}
|
||||
# COOKIES = {"c_user":"61587192741710","datr":"DD6YadZiGvjrWPeJsziYcVps","fr":"0Vx730xAppd88aMk6.AWeUeOUnFJ0z10NPAXdxjLalRp5PMdn5gCwulJ5AIgWCvqh4B0Y.BpmD7b..AAA.0.0.BpmD7b.AWf3LOz6RaIIheJztf4K8-0urhQ","xs":"17:X737_mFveQOCjg:2:1771585246:-1:-1"}
|
||||
# COOKIES = {"c_user":"61574261924177","datr":"b93aaSfufy7KSzEBmShfLqJY","fr":"07L77tEMETzACXCvv.AWf_o6-uoxdbOQ8QiEmrVt5bIP2gVfdf4e3R0w4Eg205Eg0xsms.Bp2t3j..AAA.0.0.Bp2t3j.AWcrnpRZr2VJOMU94nUAXFmq2x8","xs":"44:yPtMHPoNucdZCg:2:1775951339:-1:-1"}
|
||||
|
||||
TARGET_URL = "https://www.facebook.com/permalink.php?story_fbid=pfbid023QsxMBw26HAdt3LW1Ln7GUugWYbQkzfL9Ws68XUiuaXJvFD3u1iKtVFq7hpypdFtl&id=61580561183111"
|
||||
# COOKIES = {"c_user":"61570694932587","datr":"P1graE1OpoAazqfOOl-bX3Fu","oo":"v13:1776064962","xs":"33:nSmF-tHC6p4SOg:2:1776064969:-1:-1"}
|
||||
# COOKIES = {"c_user":"61573351360189","datr":"Jd7aadJGfdlqf2PaC8Esc_Ty","oo":"v13:1775951530","xs":"19:bv_rfhwfD3PX0w:2:1775951539:-1:-1"}
|
||||
# COOKIES = {"c_user":"61572352414179","datr":"cXnaaXLZcbL6cXIejDKcUarc","oo":"v13:1775925753","xs":"34:-eVFsriAzPFVVQ:2:1775925759:-1:-1"}
|
||||
COOKIES = {"c_user":"61572977825069","datr":"ALXaaW5Q-bJ7_gQWTjU-Qosd","oo":"v13:1775940979","xs":"16:A9ieAMX5SjNUBQ:2:1775940983:-1:-1"}
|
||||
|
||||
TARGET_URL = "https://www.facebook.com/permalink.php?story_fbid=pfbid026dQik7NyujSGd2rjWyTKbQVw2CVM5BeJEP9sYxo7K5TBGhWZ4sUfs4gMoSLKq2mJl&id=61575372223339"
|
||||
|
||||
CONTENT = "You’ve earned my admiration with this quality."
|
||||
|
||||
|
||||
Reference in New Issue
Block a user