Skip to content

Instantly share code, notes, and snippets.

View thiagopnobre's full-sized avatar

Thiago Pereira Nobre thiagopnobre

  • UFLA - Universidade Federal de Lavras
View GitHub Profile
@thiagopnobre
thiagopnobre / unshorten_url.py
Last active August 29, 2015 14:14
Algoritmo para desencurtar URLs obtido do stackoverflow seguido da refatoração que fiz.
# Código original
import httplib
import urlparse
def unshorten_url(url):
parsed = urlparse.urlparse(url)
h = httplib.HTTPConnection(parsed.netloc)
resource = parsed.path
if parsed.query != "":
resource += "?" + parsed.query
@thiagopnobre
thiagopnobre / erros_desencurtamento.txt
Last active August 29, 2015 14:14
Arquivo de erros no desencurtamento de URLs utilizando o algoritmo refatorado contido no link: https://gist.github.com/thiagopnobre/31ff07112ef4961d0c20.
Unshorten error at URL: http://t.co/0AMa7HVsL8
Unshorten error at URL: http://t.co/wxWQpQB6lD
Unshorten error at URL: http://t.co/wxWQpQB6lD
Unshorten error at URL: http://t.co/o17p11agSh
Unshorten error at URL: http://t.c
Unshorten error at URL: http://
Unshorten error at URL: http://t
Unshorten error at URL: http:/
Unshorten error at URL: http://
Unshorten error at URL: http://t.co/Gk6FxA8E6Z
@thiagopnobre
thiagopnobre / corrigido.py
Last active August 29, 2015 14:16
Código de teste para buscar páginas em um XML baseado no dumps da Wikipedia.
# Correção feita com ajuda de Bernardo Torres (https://github.com/bernardotorres)
from xml.etree import cElementTree
with open('teste.xml') as arquivo:
xml_content = arquivo.read()
content = cElementTree.fromstring(xml_content)
namespaces = {
'wiki': 'http://www.mediawiki.org/xml/export-0.10/'