Skip to content

Instantly share code, notes, and snippets.

@macndesign
Created May 12, 2016 14:45
Show Gist options
  • Save macndesign/20a8b45434f4d0b699cb713b8706d3ec to your computer and use it in GitHub Desktop.
Save macndesign/20a8b45434f4d0b699cb713b8706d3ec to your computer and use it in GitHub Desktop.
import requests
def get_desc(link):
r = requests.get(link)
text_list = r.text.split('\n')
data = {}
for i, t in enumerate(text_list):
data['url'] = r.url
if '<h4>Lote' in t:
data['lote'] = int(t.replace('<h4>', '').replace('</h4>', '').replace('Lote ', '').strip())
if 'Descri&ccedil;&atilde;o do Lote' in t:
data['desc'] = text_list[i + 3].replace('<p>', '').replace('<br />', '').strip()
if 'Comitente' in t:
data['com'] = text_list[i + 1].replace('<td class="campo">', '').replace('</td>', '').strip()
return data
if __name__ == '__main__':
url_base = 'http://www.montenegroleiloes.com.br/lotes/visualizar/'
initial = 42883
com = 'bradesco'
while 'bradesco' in com.lower():
try:
desc = get_desc(url_base + str(initial))
com = desc['com']
if 'bradesco' in com.lower():
print(desc)
initial += 1
except Exception:
print('Broken')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment