登录验证码
This commit is contained in:
@@ -848,7 +848,7 @@ def playwright_like(cookies, target_url):
|
||||
try:
|
||||
page.goto(url)
|
||||
time.sleep(random.randint(3, 10))
|
||||
check_account_status(page, parse_cookies(cookies))
|
||||
# check_account_status(page, parse_cookies(cookies))
|
||||
|
||||
if 'permalink.php?story_fbid' in target_url or '/posts/' in target_url:
|
||||
# 文字或图片类型
|
||||
@@ -1187,26 +1187,26 @@ def playwright_login(username, password, code_2fa=None):
|
||||
page.reload()
|
||||
time.sleep(random.randint(1, 10))
|
||||
|
||||
# captcha_img = page.query_selector_all('//img[contains(@src, "captcha")]')
|
||||
# if captcha_img:
|
||||
# img_file_path = os.path.join(BASE_PATH, 'files', 'captcha.png')
|
||||
# captcha_img[0].screenshot(path=img_file_path)
|
||||
# with open(img_file_path, 'rb') as f:
|
||||
# data = {
|
||||
# 'user': 'shaowz',
|
||||
# 'pass2': '69e86586e8a1241719ebacecf7bb84c2',
|
||||
# 'softid': '951004',
|
||||
# 'codetype': '3006',
|
||||
# }
|
||||
# response = requests.post('http://upload.chaojiying.net/Upload/Processing.php',
|
||||
# data=data, timeout=60, files={'userfile': f})
|
||||
# result = response.json()
|
||||
# if result['err_no'] == 0:
|
||||
# pic_str = result['pic_str']
|
||||
# page.fill('//img[contains(@src, "captcha")]/parent::div/parent::div//input', pic_str)
|
||||
# page.locator('//img[contains(@src, "captcha")]/parent::div/parent::div/div').nth(4).click()
|
||||
# else:
|
||||
# raise OperationFailed('验证码解析错误')
|
||||
captcha_img = page.query_selector_all('//img[contains(@src, "captcha")]')
|
||||
if captcha_img:
|
||||
img_file_path = os.path.join(BASE_PATH, 'files', 'captcha.png')
|
||||
captcha_img[0].screenshot(path=img_file_path)
|
||||
with open(img_file_path, 'rb') as f:
|
||||
data = {
|
||||
'user': 'shaowz',
|
||||
'pass2': '69e86586e8a1241719ebacecf7bb84c2',
|
||||
'softid': '951004',
|
||||
'codetype': '3006',
|
||||
}
|
||||
response = requests.post('http://upload.chaojiying.net/Upload/Processing.php',
|
||||
data=data, timeout=60, files={'userfile': f})
|
||||
result = response.json()
|
||||
if result['err_no'] == 0:
|
||||
pic_str = result['pic_str']
|
||||
page.fill('//img[contains(@src, "captcha")]/parent::div/parent::div//input', pic_str)
|
||||
page.locator('//img[contains(@src, "captcha")]/parent::div/parent::div/div').nth(4).click()
|
||||
else:
|
||||
raise OperationFailed('验证码解析错误')
|
||||
time.sleep(5)
|
||||
page.wait_for_load_state()
|
||||
h2 = page.query_selector("//h2/span")
|
||||
@@ -1280,7 +1280,7 @@ if __name__ == '__main__':
|
||||
# )
|
||||
cookies = '{"c_user":"61565405263653","datr":"-YDhZoLWu5zbUIw5cOB2In9s","fr":"0ZmsqLWbmV0Onlspt.AWW1JRfVxQAF-jl0oGY7lBQLYq4.Bm4YD5..AAA.0.0.Bm4YED.AWVf1ae03r4","m_page_voice":"61565405263653","m_pixel_ratio":"2.625","sb":"-YDhZs8LozUoyLe1gj2MCUwW","wd":"412x759","xs":"21%3A8Gt3CwtjVWJUhQ%3A2%3A1726054660%3A-1%3A-1"}'
|
||||
# print(playwright_check_account_cookies(cookies))
|
||||
print(playwright_comment(cookies, "https://www.facebook.com/groups/1564190847667055/posts/1918780732208063/", "wow"))
|
||||
# cookies = playwright_login('61575975148121', 'Mu1711rstu1999', 'JNCCTXB34EP5ME6RU6RND6SHBQ6KATAR')
|
||||
print(playwright_like(cookies, "https://www.facebook.com/groups/1070754870427928/permalink/1873461830157224/"))
|
||||
cookies = playwright_login('61575975148121', 'Mu1711rstu1999', 'JNCCTXB34EP5ME6RU6RND6SHBQ6KATAR')
|
||||
# print(cookies)
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user