@@ -47,7 +47,7 @@ class FacebookExceptionProcessor(BaseException, WebActions):
47
47
- 1 : {'name' : 'unknown' },
48
48
0 : {'name' : 'home' ,
49
49
'key_words' : {'mobile' : {"css" : ['div[id="MComposer"]' ], "xpath" : []},
50
- "pc" : {"css" : ['div[id="MComposerPC "]' ]}}},
50
+ "pc" : {"css" : ['input[data-testid="search_input "]' ]}}},
51
51
1 : {'name' : 'remember_password' ,
52
52
'key_words' : {"mobile" : {"css" : ['a[href^="/login/save-device/cancel/?"]' , 'button[type="submit"]' ]},
53
53
"pc" : {"css" : []}}},
@@ -62,7 +62,7 @@ class FacebookExceptionProcessor(BaseException, WebActions):
62
62
"pc" : {"css" : []}}},
63
63
5 : {'name' : 'account_invalid' ,
64
64
'key_words' : {"mobile" : {"css" : ['div[class^="mvm uiP fsm"]' ]},
65
- "pc" : {"css" : ['div[class^="mvm uiP fsm "]' ]}},
65
+ "pc" : {"css" : ['button[name="submit[Download Your Information] "]' ]}},
66
66
'account_status' : 'invalid' },
67
67
6 : {'name' : 'auth_button_two_verify' ,
68
68
'key_words' : {"mobile" : {"css" : ('button[name="submit[Continue]' , 'div[id="checkpoint_subtitle"]' )},
@@ -74,23 +74,23 @@ class FacebookExceptionProcessor(BaseException, WebActions):
74
74
'account_status' : 'verifying_sms' },
75
75
8 : {'name' : 'photo_verify' ,
76
76
'key_words' : {"mobile" : {"css" : ['input[name="photo-input"]' , 'input[id="photo-input"]' ]},
77
- "pc" : {"css" : []}},
77
+ "pc" : {"css" : ['input[name="photo-input"]' , 'input[id="photo-input"]' ]}},
78
78
'account_status' : 'verifying_photo' },
79
79
9 : {'name' : 'auth_button_one_verify' ,
80
80
'key_words' : {"mobile" : {"css" : ['button[name="submit[Secure Account]"]' ]},
81
81
"pc" : {"css" : []}},
82
82
'account_status' : 'verifying_auth_button_one' },
83
83
10 : {'name' : 'email_verify' ,
84
84
'key_words' : {"mobile" : {"css" : ['input[placeholder="######"]' ]},
85
- "pc" : {"css" : []}},
85
+ "pc" : {"css" : ['input[placeholder="######"]' ]}},
86
86
'account_status' : 'verifying_email_code' },
87
87
11 : {'name' : 'sms_verify' ,
88
88
'key_words' : {"mobile" : {"css" : ['input[name="p_c"]' ]},
89
89
"pc" : {"css" : []}},
90
90
'account_status' : 'verifying_sms_code' },
91
91
12 : {'name' : 'wrong_password' ,
92
92
'key_words' : {"mobile" : {"css" : ['a[href^="/recover/initiate/?ars=facebook_login_pw_error&lwv"]' ]},
93
- "pc" : {"css" : []}},
93
+ "pc" : {"css" : ['a[class="accessible_elem layer_close_elem"]' ]}},
94
94
'account_status' : 'verifying_wrong_password' },
95
95
13 : {'name' : 'shared_login' ,
96
96
'key_words' : {"mobile" : {"css" : ['a[href^="https://facebook.com/mobile/click/?redir_url=https"]' ]},
@@ -242,7 +242,7 @@ def check_func(self, key_words, wait=3):
242
242
if iframe :
243
243
for ifa in iframe :
244
244
self .driver .switch_to .frame (ifa )
245
- time .sleep (1 )
245
+ self .sleep (1 , 1 )
246
246
247
247
WebDriverWait (self .driver , wait ).until (
248
248
EC .presence_of_element_located ((key_words_type , key )))
@@ -291,7 +291,7 @@ def process_save_phone_number_mobile_mobile(self):
291
291
tel_number = WebDriverWait (self .driver , 6 ).until (
292
292
EC .presence_of_element_located ((By .CSS_SELECTOR , self .get_key_words (2 ))))
293
293
self .click (tel_number )
294
- time .sleep (3 )
294
+ self .sleep ()
295
295
except Exception as e :
296
296
logger .exception ("忽略输入电话号码处理异常, e={}" .format (e ))
297
297
return False , 2
@@ -322,7 +322,7 @@ def process_download_app_mobile(self):
322
322
:return: 成功返回 True, 失败返回 False
323
323
"""
324
324
325
- time .sleep (3 )
325
+ self .sleep ()
326
326
try :
327
327
logger .info ('忽略下载app处理中' )
328
328
never_save_number = WebDriverWait (self .driver , 6 ).until (
@@ -351,6 +351,23 @@ def process_account_invalid_mobile(self):
351
351
logger .info ("账号被封杀" )
352
352
return False , 5
353
353
354
+ def process_account_invalid_pc (self ):
355
+ """
356
+ # 账号被封杀
357
+ :param kwargs:
358
+ :return: 成功返回 True, 失败返回 False
359
+ """
360
+ try :
361
+ logger .info ('账号被封杀处理中' )
362
+ never_save_number = WebDriverWait (self .driver , 6 ).until (
363
+ EC .presence_of_element_located ((By .CSS_SELECTOR , self .get_key_words (5 ))))
364
+ self .click (never_save_number )
365
+ except Exception as e :
366
+ logger .exception ("账号被封杀处理异常, e={}" .format (e ))
367
+ return False , 5
368
+ logger .info ("账号被封杀" )
369
+ return False , 5
370
+
354
371
def process_auth_button_two_verify_mobile (self ):
355
372
"""
356
373
身份验证类型二,跳转按钮
@@ -416,7 +433,7 @@ def process_phone_sms_verify_pc(self):
416
433
self .click (sub_button )
417
434
except :
418
435
pass
419
- rtime = random . randint ( 2 , 4 )
436
+
420
437
try :
421
438
tel_button = self .driver .find_elements_by_css_selector ('i[class^="img sp_"]' )
422
439
if not tel_button :
@@ -427,11 +444,11 @@ def process_phone_sms_verify_pc(self):
427
444
tel_stutas = self .driver .find_elements_by_css_selector ('a[role="menuitemcheckbox"]' )
428
445
self .click (tel_stutas [45 ])
429
446
430
- time .sleep (rtime )
447
+ self .sleep ()
431
448
send_tel = self .driver .find_element_by_css_selector ('input[type="tel"]' )
432
449
self .send_keys (send_tel , "16500000000" )
433
450
434
- time .sleep (rtime )
451
+ self .sleep ()
435
452
submit_button = self .driver .find_element_by_css_selector ('button[id="checkpointSubmitButton"]' )
436
453
self .click (submit_button )
437
454
@@ -445,11 +462,11 @@ def process_phone_sms_verify_pc(self):
445
462
except :
446
463
pass
447
464
# 短信验证码
448
- time .sleep (rtime )
465
+ self .sleep ()
449
466
tel_code = self .driver .find_element_by_css_selector ('input[name="p_c"]' )
450
467
self .send_keys (tel_code , "414141" )
451
468
452
- time .sleep (rtime )
469
+ self .sleep ()
453
470
submit_button = self .driver .find_element_by_css_selector ('button[id="checkpointSubmitButton"]' )
454
471
self .click (submit_button )
455
472
@@ -500,6 +517,47 @@ def process_photo_verify_mobile(self):
500
517
logger .info ("处理上传图片验证的完成" )
501
518
return True , 8
502
519
520
+ def process_photo_verify_pc (self ):
521
+ """
522
+ # 上传图片验证
523
+ :param kwargs:
524
+ :return: 成功返回 True, 失败返回 False
525
+ """
526
+ try :
527
+ logger .info ("处理上传图片验证处理中" )
528
+ photo_upload = WebDriverWait (self .driver , 6 ).until (
529
+ EC .presence_of_element_located ((By .CSS_SELECTOR , self .get_key_words (8 ))))
530
+
531
+ photo_path = get_photo (self .account , self .gender )
532
+ logger .info ('process_photo_verify photo path={}' .format (photo_path ))
533
+ if not photo_path :
534
+ return False , 8
535
+ # photo_path = 'E:\\IMG_3563.JPG'
536
+ # 上传图片
537
+ self .send_keys (photo_upload , photo_path )
538
+ # photo_upload.send_keys(photo_path)
539
+ # 点击继续
540
+ phone_button = WebDriverWait (self .driver , 6 ).until (
541
+ EC .presence_of_element_located ((By .CSS_SELECTOR , 'button[id="checkpointSubmitButton-actual-button"]' )))
542
+ self .click (phone_button )
543
+ # 重新检查页面
544
+ photo_btn = WebDriverWait (self .driver , 6 ).until (
545
+ EC .presence_of_element_located ((By .CSS_SELECTOR , 'button[name="submit[OK]"]' )))
546
+ if photo_btn :
547
+ logger .info ("photo uploaded successfully!" )
548
+ account_photo_path = os .path .join (os .path .dirname (os .path .dirname (photo_path )),
549
+ "{}.jpg" .format (self .account ))
550
+ shutil .move (photo_path , account_photo_path )
551
+ logger .info ("process photo verify succeed, photo path={}" .format (account_photo_path ))
552
+ else :
553
+ logger .warning ("process photo verify unfinished, photo path={}" .format (photo_path ))
554
+ os .remove (photo_path )
555
+ except Exception as e :
556
+ logger .exception ("上传照片验证异常, e={}" .format (e ))
557
+ return False , 8
558
+ logger .info ("处理上传图片验证的完成" )
559
+ return True , 8
560
+
503
561
def process_auth_button_one_verify_mobile (self ):
504
562
"""
505
563
身份验证类型一,跳转按钮
@@ -536,6 +594,24 @@ def process_email_verify_mobile(self):
536
594
logger .info ("登录邮箱数字验证码验证处理完成" )
537
595
return True , 10
538
596
597
+ def process_email_verify_pc (self ):
598
+ """
599
+ 登录邮箱数字验证码验证
600
+ :param kwargs:
601
+ :return: 成功返回 True, 失败返回 False
602
+ """
603
+ try :
604
+ logger .info ("登录邮箱数字验证码验证处理中" )
605
+ check_button = WebDriverWait (self .driver , 6 ).until (
606
+ EC .presence_of_element_located (
607
+ (By .CSS_SELECTOR , self .get_key_words (10 ))))
608
+ self .click (check_button )
609
+ except Exception as e :
610
+ logger .exception ("登录邮箱数字验证码验证处理异常, e={}" .format (e ))
611
+ return False , 10
612
+ logger .info ("登录邮箱数字验证码验证处理完成" )
613
+ return True , 10
614
+
539
615
def process_sms_verify_mobile (self ):
540
616
"""
541
617
短信验证码验证
@@ -572,6 +648,23 @@ def process_wrong_password_mobile(self):
572
648
logger .info ("账号密码不正确" )
573
649
return False , - 1
574
650
651
+ def process_wrong_password_pc (self ):
652
+ """
653
+ 账号密码不正确
654
+ :param kwargs:
655
+ :return: 成功返回 True, 失败返回 False
656
+ """
657
+ try :
658
+ logger .info ("账号密码不正确 处理中" )
659
+ WebDriverWait (self .driver , 6 ).until (
660
+ EC .presence_of_element_located (
661
+ (By .CSS_SELECTOR , self .get_key_words (12 ))))
662
+ except Exception as e :
663
+ logger .exception ("账号密码不正确处理异常, e={}" .format (e ))
664
+ return False , - 1
665
+ logger .info ("账号密码不正确" )
666
+ return False , - 1
667
+
575
668
def process_shared_login_mobile (self ):
576
669
"""
577
670
移动端手机共享登录验证
0 commit comments