source: phonelux_scrappers/phone_total_offers.py@ 47f4eaf

Last change on this file since 47f4eaf was 895cd87, checked in by Marko <Marko@…>, 21 months ago

Refactored code

  • Property mode set to 100644
File size: 557 bytes
RevLine 
[895cd87]1import json
[527b93f]2
3import psycopg2
[895cd87]4import requests
[527b93f]5import config_read
6import sys
7
8file_path = 'outputfile.txt'
9sys.stdout = open(file_path, "w")
10
11
[895cd87]12phones = json.loads(requests.get('http://localhost:8080/phones').text)
[527b93f]13
14for phone in phones:
15
[895cd87]16 phone_id = str(phone['id'])
17 totaloffers = requests.get('http://localhost:8080/totaloffers/'+str.join('*', phone['model'].split(' '))).text
[527b93f]18
[895cd87]19 print(phone_id+' - '+totaloffers)
[527b93f]20
[895cd87]21 # UPDATE DATABASE WITH NEW TOTAL OFFERS
22 requests.put('http://localhost:8080/settotaloffers/' + phone_id + '/' + totaloffers)
Note: See TracBrowser for help on using the repository browser.