Skip to content

Incredibly fast crawler designed for OSINT.

Adding code to detect and report broken links.

sneh-me0797d2d49d2
diff --git a/photon.py b/photon.py
index a3d261c..77cce6b 100644
--- a/photon.py
+++ b/photon.py
@@ -137,15 +137,15 @@ def requester(url):
'Accept-Encoding' : 'gzip',
'DNT' : '1',
'Connection' : 'close'}
- # make request and return response body
- return get(url, cookies=cook, headers=headers, verify=False).text
+ # make request and return response
+ return get(url, cookies=cook, headers=headers, verify=False)
# pixlr.com API
def pixlr(url):
if url == main_url:
url = main_url + '/' # because pixlr throws error if http://example.com is used
- # make request and return response body
- return get('https://pixlr.com/proxy/?url=' + url, headers={'Accept-Encoding' : 'gzip'}, verify=False).text
+ # make request and return response
+ return get('https://pixlr.com/proxy/?url=' + url, headers={'Accept-Encoding' : 'gzip'}, verify=False)
# codebeautify.org API
def code_beautify(url):
@@ -157,19 +157,34 @@ def requester(url):
'Origin' : 'https://codebeautify.org',
'Connection' : 'close'
}
- # make request and return response body
- return post('https://codebeautify.com/URLService', headers=headers, data='path=' + url, verify=False).text
+ # make request and return response
+ return post('https://codebeautify.com/URLService', headers=headers, data='path=' + url, verify=False)
# www.photopea.com API
def photopea(url):
- # make request and return response body
- return get('https://www.photopea.com/mirror.php?url=' + url, verify=False).text
+ # make request and return response
+ return get('https://www.photopea.com/mirror.php?url=' + url, verify=False)
if ninja: # if the ninja mode is enabled
# select a random request function i.e. random API
- return random.choice([photopea, normal, pixlr, code_beautify])(url)
+ response = random.choice([photopea, normal, pixlr, code_beautify])(url)
+
+ #check if link is not broken
+ if(response.status_code != 200):
+ raise Exception("broken link!")
+
+ #if response is Ok, return response body
+ return response.text;
else:
- return normal(url)
+ response = normal(url)
+
+ #check if link is not broken
+ if(response.status_code != 200):
+ raise Exception("broken link!")
+
+ #if response is Ok, return response body
+ return response.text;
+
except: # if photon fails to connect to the url
failed.add(url) # add it to the failed list