Created
July 12, 2019 10:35
-
-
Save aruna09/38222d7f30ee3c40a7cd32ba85ca7059 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#from requests.exceptions import HTTPError | |
import requests | |
outfile = open("output.txt", "w") | |
with open('url.txt', 'r+') as f: | |
for line in f: | |
line = line.rstrip('\n') + '/.git/HEAD' | |
line = 'http://'+line | |
outfile.write(line) | |
outfile.write('\n') | |
outfile.close() | |
with open('output.txt', 'r') as f: | |
for line in f: | |
line = line.rstrip('\n') | |
print(line) | |
try: | |
response = requests.get(line) | |
content = response.text | |
if(len(content)==0): | |
print("No content found") | |
else: | |
print("Looks like we found something!") | |
response.raise_for_status() | |
except HTTPError as http_err: | |
print(f'HTTP error occurred: {http_err}') # Python 3.6 | |
except Exception as err: | |
print(f'Other error occurred: {err}') # Python 3.6 | |
else: | |
print('Success! .git repo found') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment