修复点赞找不到按钮
This commit is contained in:
@@ -291,15 +291,12 @@ def playwright_like(cookies, target_url):
|
|||||||
|
|
||||||
retry_goto(page, url)
|
retry_goto(page, url)
|
||||||
time.sleep(random.randint(3, 10))
|
time.sleep(random.randint(3, 10))
|
||||||
if 'permalink.php?story_fbid' in target_url or '/posts/' in target_url:
|
if 'permalink.php?story_fbid' in target_url or '/permalink/' in target_url or '/posts/' in target_url:
|
||||||
# 文字或图片类型
|
# 文字或图片类型
|
||||||
button_xpath = '//*[@role="dialog"]//span[text()="Like" or @data-ad-rendering-role="like_button"]'
|
button_xpath = '//*[@role="dialog"]//span[text()="Like" or @data-ad-rendering-role="like_button"]'
|
||||||
elif 'watch/?v' in target_url or '/videos/' in target_url:
|
elif 'watch/?v' in target_url or '/videos/' in target_url:
|
||||||
# 视频类型, 视频类型,
|
# 视频类型, 视频类型,
|
||||||
button_xpath = '//span[@data-ad-rendering-role="like_button"][1]'
|
button_xpath = '//span[@data-ad-rendering-role="like_button"][1]'
|
||||||
elif '/permalink/' in target_url:
|
|
||||||
# 永久链接
|
|
||||||
button_xpath = '//*[@role="dialog"]//span[@data-ad-rendering-role="like_button"]'
|
|
||||||
elif '/reel/' in target_url:
|
elif '/reel/' in target_url:
|
||||||
# 短视频类型
|
# 短视频类型
|
||||||
button_xpath = '//div[@class="__fb-dark-mode x1afcbsf x1uhb9sk x1swf91x"]//div[@aria-label="Like"]//div[@aria-label="Like"]'
|
button_xpath = '//div[@class="__fb-dark-mode x1afcbsf x1uhb9sk x1swf91x"]//div[@aria-label="Like"]//div[@aria-label="Like"]'
|
||||||
@@ -1071,7 +1068,7 @@ if __name__ == '__main__':
|
|||||||
# print(playwright_get_user_profile(cookies))
|
# print(playwright_get_user_profile(cookies))
|
||||||
# # 永久链接的帖子点赞
|
# # 永久链接的帖子点赞
|
||||||
# print(playwright_like(cookies, "https://www.facebook.com/groups/1070754870427928/permalink/1873461830157224/"))
|
# print(playwright_like(cookies, "https://www.facebook.com/groups/1070754870427928/permalink/1873461830157224/"))
|
||||||
print(playwright_like(cookies, "https://www.facebook.com/permalink.php?story_fbid=pfbid037z3vCbfQXaohJT3P2Td7oKfgEZ7uKBG2zt7FktDwarsx5DftReNBrks1SuRwzApFl&id=61556406998616"))
|
print(playwright_like(cookies, "https://www.facebook.com/groups/267112859525987/permalink/658047397099196/?rdid=LETw8B1KYb7eUKUJ"))
|
||||||
#
|
#
|
||||||
# # # 视频链接的帖子点赞
|
# # # 视频链接的帖子点赞
|
||||||
# print(playwright_like(cookies, "https://www.facebook.com/groups/1070754870427928/permalink/1873461830157224/"))
|
# print(playwright_like(cookies, "https://www.facebook.com/groups/1070754870427928/permalink/1873461830157224/"))
|
||||||
|
|||||||
Reference in New Issue
Block a user