Skip to content

Commit

Permalink
Fixed issue with crashing while logging in
Browse files Browse the repository at this point in the history
- Fixed issue with crashing while logging in due to a TypeError caused by the use of unary "+" operator on a string. The issue was resolved by removing the "+" signs from lines 95 and 101 of the AO3_Scraper.py file. The corrected lines now correctly print whether the login was successful or failed using the Fore.GREEN and Fore.RESET variables.
- updated requirements
- closure statement was updated to exit after displaying the closing message
  • Loading branch information
Dramatycznie committed Mar 21, 2023
1 parent 5bb77ca commit 912fdeb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
21 changes: 11 additions & 10 deletions AO3_Scraper.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import requests
from bs4 import BeautifulSoup
import time
import csv
from tqdm import tqdm
from requests.exceptions import RequestException
import re
import sys
from colorama import init, Fore
import time

import requests
from bs4 import BeautifulSoup
from colorama import Fore
from requests.exceptions import RequestException
from tqdm import tqdm

# Set global variables
token = None
Expand Down Expand Up @@ -92,13 +93,13 @@
if "Successfully logged in" in p.text:
# Login successful
print("")
print(+ Fore.GREEN + "Login successful" + Fore.RESET)
print(Fore.GREEN + "Login successful" + Fore.RESET)
break
# If the login is successful, break out of the loop
else:
# Login failed
print("")
print(+ Fore.GREEN + "Login failed" + Fore.RESET)
print(Fore.GREEN + "Login failed" + Fore.RESET)
continue
# If the login is not successful, ask the user to enter the credentials again

Expand Down Expand Up @@ -486,8 +487,8 @@
# Close the program
print("")
print("Thank you for using the AO3 Bookmark Scraper!")
time.sleep(1)
break
# Exit the program
sys.exit(2)
# If the user enters something other than 'y' or 'n'
else:
# Ask the user to enter 'y' or 'n'
Expand Down
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
requests~=2.28.2
beautifulsoup4~=4.11.1
tqdm~=4.64.1
beautifulsoup4==4.12.0
tqdm==4.65.0
colorama~=0.4.6

0 comments on commit 912fdeb

Please sign in to comment.