| @@ 460-476 (lines=17) @@ | ||
| 457 | elif status_code==403: |
|
| 458 | print("[Error] Maximum number of login attempts exceeded") |
|
| 459 | sys.exit() |
|
| 460 | else: |
|
| 461 | print("[Error] in " + user + " unfollow!") |
|
| 462 | else: |
|
| 463 | print(user+" Unfollowed") |
|
| 464 | time.sleep(3) |
|
| 465 | return True |
|
| 466 | def follow(username,password,id_list): |
|
| 467 | for user in id_list: |
|
| 468 | response = requests.put("https://api.github.com/user/following/" + user, auth=(username, password)) |
|
| 469 | status_code = int(response.status_code) |
|
| 470 | if status_code!=204: |
|
| 471 | if status_code==401: |
|
| 472 | print("[Error] Authentication Error") |
|
| 473 | return False |
|
| 474 | elif status_code==403: |
|
| 475 | print("[Error] Maximum number of login attempts exceeded") |
|
| 476 | sys.exit() |
|
| 477 | else: |
|
| 478 | print("[Error] in "+user+" follow!") |
|
| 479 | else: |
|
| @@ 443-459 (lines=17) @@ | ||
| 440 | file = open(username + "_NotFollowing.log", "w") |
|
| 441 | dif_list_2 = list(set(list_1) - set(list_2)) |
|
| 442 | print(str(len(dif_list_2)) + " Follower - Not Following --> " + username + "_NotFollowing.log") |
|
| 443 | print_line(70, "*") |
|
| 444 | file.write("\n".join(dif_list_2)) |
|
| 445 | file.close() |
|
| 446 | return [sorted(dif_list_1),sorted(dif_list_2)] |
|
| 447 | except Exception as ex: |
|
| 448 | print("[Error] dif function faild") |
|
| 449 | def unfollow(username,password,id_list): |
|
| 450 | for user in id_list: |
|
| 451 | response=requests.delete("https://api.github.com/user/following/" + user, auth=(username, password)) |
|
| 452 | status_code=int(response.status_code) |
|
| 453 | if status_code!=204: |
|
| 454 | if status_code==401: |
|
| 455 | print("[Error] Authentication Error") |
|
| 456 | return False |
|
| 457 | elif status_code==403: |
|
| 458 | print("[Error] Maximum number of login attempts exceeded") |
|
| 459 | sys.exit() |
|
| 460 | else: |
|
| 461 | print("[Error] in " + user + " unfollow!") |
|
| 462 | else: |
|