Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def exclude_url(exclude, link):
rp.set_url(arg.domain+"robots.txt")
rp.read()


responseCode={}
print (header, file=output_file)
while tocrawl:
crawling = tocrawl.pop()
Expand All @@ -134,7 +134,15 @@ def exclude_url(exclude, link):
try:
request = Request(crawling, headers={"User-Agent":'Sitemap crawler'})
response = urlopen(request)
msg = response.read()
if response.getcode() in responseCode:
responseCode[response.getcode()]+=1
else:
responseCode[response.getcode()] = 0
if response.getcode()==200:
msg = response.read()
else:
msg = ""

response.close()
except Exception as e:
if arg.debug:
Expand Down Expand Up @@ -170,5 +178,8 @@ def exclude_url(exclude, link):
if arg.debug:
logging.debug ("Number of link crawled : {0}".format(len(crawled)))

for code in responseCode:
logging.debug ("Nb Code HTTP {0} : {1}".format(code, responseCode[code]))

if output_file:
output_file.close()
output_file.close()