Line | |
---|
1 | import requests
|
---|
2 | import sys
|
---|
3 | import unicodedata
|
---|
4 | import json
|
---|
5 | from classes.phone import Phone
|
---|
6 | from classes.phoneoffer import PhoneOffer
|
---|
7 |
|
---|
8 | file_path = 'outputfile.txt'
|
---|
9 | sys.stdout = open(file_path, "w")
|
---|
10 |
|
---|
11 | # testing connection with spring backend app
|
---|
12 | # print(unicodedata.normalize('NFKD', str(requests.get("http://localhost:8080/phoneoffer/7").text)))
|
---|
13 |
|
---|
14 | offers = json.loads(unicodedata.normalize('NFKD', requests.get('http://localhost:8080/phoneoffer/shop/a1').text))
|
---|
15 |
|
---|
16 |
|
---|
17 | phoneOffers = []
|
---|
18 |
|
---|
19 | for offer in offers:
|
---|
20 | phoneOffer = PhoneOffer(offer['id'], offer['offer_shop'], offer['offer_name'], offer['price'], offer['ram_memory'],
|
---|
21 | offer['rom_memory'], offer['color'], offer['front_camera'], offer['back_camera'],
|
---|
22 | offer['chipset'], offer['battery'], offer['operating_system'], offer['cpu'], offer['image_url'],
|
---|
23 | offer['offer_url'], offer['last_updated'], offer['is_validated'], offer['offer_description'],
|
---|
24 | offer['offer_shop_code'])
|
---|
25 | phoneOffers.append(phoneOffer)
|
---|
26 |
|
---|
27 | for offer in phoneOffers:
|
---|
28 | print(offer)
|
---|
29 |
|
---|
30 |
|
---|
31 |
|
---|
32 |
|
---|
33 |
|
---|
34 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.