Created
May 12, 2016 14:45
-
-
Save macndesign/20a8b45434f4d0b699cb713b8706d3ec to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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çã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