source: phonelux_scrappers/phones_model_setter.py

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

Final features implemented

  • Property mode set to 100644
File size: 819 bytes
Line 
1import json
2import unicodedata
3import requests
4import classes.phone
5import sys
6
7
8file_path = 'outputfile.txt'
9sys.stdout = open(file_path, "w")
10
11phones = json.loads(requests.get('http://localhost:8080/phones').text)
12offers = json.loads(requests.get('http://localhost:8080/alloffers').text)
13phones.sort(key=lambda p: p['model'], reverse=True)
14offers.sort(key=lambda o: o['offer_name'])
15
16for offer in offers:
17 flag = False
18 for phone in phones:
19 if phone['model'].lower() in offer['offer_name'].lower():
20 flag = True
21 # Add phone model to offer
22 requests.put('http://localhost:8080/phoneoffer/'+str(offer['id'])+'/addphonemodel/'+str(phone['id']))
23 break
24 if not flag:
25 requests.delete('http://localhost:8080/phoneoffer/deleteoffer/' + str(offer['id']))
Note: See TracBrowser for help on using the repository browser.