From 08ddd95461360b17c9fe55baabdb36d0af54bccb Mon Sep 17 00:00:00 2001 From: Mylloon Date: Mon, 23 Aug 2021 13:39:18 +0200 Subject: [PATCH] now the connection is working --- main.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index e4d5dca..f246b7d 100644 --- a/main.py +++ b/main.py @@ -17,23 +17,24 @@ class Scraper: } def errorFormat(self, code: int, message: str = "") -> str: - return f"\Error: [{code}]{' ' if len(message) > 0 else ''}{message}" + return f"Error: [{code}]{' ' if len(message) > 0 else ''}{message}" def connect(self): session = create_scraper(browser = {"browser": "chrome", "platform": "windows"}) # connect with cloudflare bypasser with a chrome browser on windows - if self.debug: print("Retrieval of the login cookie...", end = " ") + if self.debug: print("Retrieval of the login SID...", end = " ") reponse = session.get(f"{self.url}/ucp.php?mode=login") # get login page to get "sid" if reponse.status_code != 200: - raise ConnectionRefusedError(self.errorFormat(reponse.status_code)) + raise ConnectionError(self.errorFormat(reponse.status_code)) self.loginData["sid"] = reponse.cookies.get_dict()["ppcw_29d3s_sid"] # register "sid" - if self.debug: print("Cookie retrieval done, connection attempt...", end = " ") + if self.debug: print("SID retrieval done, connection attempt...", end = " ") reponse = session.post(f"{self.url}/ucp.php?mode=login", data = self.loginData) # connect to the forum using credentials if reponse.status_code != 200: raise ConnectionRefusedError(self.errorFormat(reponse.status_code)) if self.debug: print("Connection done.") + reponse = session.get(f"{self.url}/index.php", cookies = reponse.cookies, params = {"sid": self.loginData["sid"]}) if self.debug: print(reponse.status_code, reponse.url) with open("temp.html", "w") as f: # debug f.writelines(reponse.text) @@ -41,8 +42,9 @@ class Scraper: return session def search(self, session): - link = "No link for your application was found." + if self.debug: print("Going to search page...", end = " ") + link = "No link for your application was found." return link def work(self):