Skip to content

Commit

Permalink
Classe responsável por pegar as principais informações de um cabeçalh…
Browse files Browse the repository at this point in the history
…o HTTP
  • Loading branch information
brunobbbs committed Sep 9, 2011
0 parents commit c0ace27
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions GetHeader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
#!/usr/bin/env python

import httplib
import socket

__author__ = 'Bruno Barbosa'


class ChecaCabecalho:
def __init__(self, *args):
self._url = args

def get_url(self):
return self._url

def get_error(self, num):
erros = {1:"Falha na conexão: O host conectado não respondeu!"}
return erros[num]


def get_cabecalho(self):

links = self.get_url()

for link in links:

conn = httplib.HTTPConnection(link)
try:
conn.request("GET", "/")
except socket.error:
return self.get_error(1)

result = conn.getresponse()

return result.status, result.reason

0 comments on commit c0ace27

Please sign in to comment.