source: phonelux_scrappers/test.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: 1.1 KB
Line 
1import requests
2import sys
3import unicodedata
4import json
5from classes.phone import Phone
6from classes.phoneoffer import PhoneOffer
7
8file_path = 'outputfile.txt'
9sys.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
14offers = json.loads(unicodedata.normalize('NFKD', requests.get('http://localhost:8080/phoneoffer/shop/a1').text))
15
16
17phoneOffers = []
18
19for 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
27for offer in phoneOffers:
28 print(offer)
29
30
31
32
33
34
Note: See TracBrowser for help on using the repository browser.