josh0xA / darkdump

Ahmia.fi Interface for Deep Web Parsing
MIT License
713 stars 135 forks source link

01/03/2022 : DarkSearch public access is now ended || Also an UnboundLocalError #9

Closed ramixix closed 1 year ago

ramixix commented 1 year ago

Hello Josh darkdump is not working anymore. When I tried to run the program for the first time, I was getting the following error: "UnboundLocalError: local variable 'json_data' referenced before assignment"

When I opened the code and started to examine it, I found that you are using two try and two except statements, that if the top try statement fails, 'Json_data' will be kind of undefined, which is why python throws UnboundLocalError. We can solve this problem by combining two try statements and write a total expect statement like the following: (lines 103 - 118)

   try:
            darksearch_url_response = requests.get(self.api, params=self.query)
            json_data = darksearch_url_response.json()
            #json_dump = json.dumps(json_data, indent=2)
            darksearch_url_response.headers["User-Agent"] = random.choice(hdrs.useragent)
            if json_data['total'] >= cfg.DARKDUMP_MIN_DATA_RETRIEVE_LENGTH: # data >= 1
                for key in range(0, 18):
                    site_title = json_data['data'][key]['title']
                    site_onion_link = json_data['data'][key]['link']
                    print(clr.BOLD + clr.G + f"[+] Site Title: {site_title}\n\t> Onion Link: {clr.R}{site_onion_link}\n" + clr.END)
        except (IndexError, requests.RequestException) as re:
            print(clr.BOLD + clr.R + str(re) + clr.END)
            print(clr.BOLD + clr.R + f"[-] No results found for query: {self.query}\n" + clr.END)

And the second issue is that the api specified __darkdump_api__ = "https://darksearch.io/api/search" on line 64 is no longer publicly accessible.

If anyone else knows a way to solve the second problem, please let me know.

josh0xA commented 1 year ago

Darkdump is finally fixed. The new version is ready for use. (Darkdump 2.0)