source: phonelux_scrappers/phone_total_offers.py

Last change on this file was 895cd87, checked in by Marko <Marko@…>, 2 years ago

Refactored code

  • Property mode set to 100644
File size: 557 bytes
Line 
1import json
2
3import psycopg2
4import requests
5import config_read
6import sys
7
8file_path = 'outputfile.txt'
9sys.stdout = open(file_path, "w")
10
11
12phones = json.loads(requests.get('http://localhost:8080/phones').text)
13
14for phone in phones:
15
16 phone_id = str(phone['id'])
17 totaloffers = requests.get('http://localhost:8080/totaloffers/'+str.join('*', phone['model'].split(' '))).text
18
19 print(phone_id+' - '+totaloffers)
20
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.