summaryrefslogtreecommitdiffstats
path: root/ebknotify/example.py
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2020-03-31 22:23:38 +0200
committermakefu <github@syntax-fehler.de>2020-03-31 22:23:38 +0200
commite4942fdab9a43712d56b38dbdb8421d38d7743df (patch)
treef45314001e9e80bcf9ca1d6ec22126db0907e751 /ebknotify/example.py
parentb9471e7b0576dfbb1157c639c4a34b243f9dd61e (diff)
ebknotify: add feed
Diffstat (limited to 'ebknotify/example.py')
-rw-r--r--ebknotify/example.py72
1 files changed, 72 insertions, 0 deletions
diff --git a/ebknotify/example.py b/ebknotify/example.py
new file mode 100644
index 0000000..bbddc19
--- /dev/null
+++ b/ebknotify/example.py
@@ -0,0 +1,72 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+ebk-client - eBay Kleinanzeigen/Classifieds API client in Python
+Copyright (c) 2016 tjado <https://github.com/tejado>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
+OR OTHER DEALINGS IN THE SOFTWARE.
+
+Author: tjado <https://github.com/tejado>
+"""
+
+from pprint import pprint
+import dateutil.parser
+from datetime import datetime
+from dateutil.tz import tzlocal
+import sys
+import json
+from ebk_client import EbkClient
+u = "ebay-kleinanzeigen.de@syntax-fehler.de"
+api = EbkClient('android', 'TaR60pEttY', u , 'se.J<I+Q~t6c:FH9de[)')
+#pprint(api._http_get("/ads.json?priceType=FREE").json())
+#pprint(api._http_get("/ads/{}.json".format( 747663143 )).json())
+#my_ads = api.get_my_ads()
+ads = api.get_ads(zipcode="70378",q="Milchaufschäumer",distance=5,distanceUnit="KM")
+#ads = api.get_ads(zipcode="70378",categoryId=192,distance=2,distanceUnit="KM")
+
+
+def nice(t):
+ return json.dumps(t,indent=4)
+
+now = datetime.now(tzlocal())
+print('Ads:')
+#print(ads)
+for ad in ads or []:
+ id = ad.get('id', 0)
+ #pprint(api.get_ad_details(id))
+ creation = ad.get('start-date-time', {}).get('value', '').encode('utf-8')
+ d = dateutil.parser.parse(creation)
+ age_in_h = (now - d).total_seconds() / 3600
+
+ title = ad.get('title', {}).get('value', '').encode('utf-8')
+ title_unescaped = api.html_unescape(title)
+ print( "{} ({}) -> {}".format(id, age_in_h, title_unescaped) )
+
+#categories = api.get_categories()
+#print(nice(categories))
+#print('Subcategories of cat 80:\n\r{}'.format(nice(categories)))
+#
+#locations = api.get_location_by_name('70378')
+#print('Location by german postcode 70378:\n\r{}'.format(nice(locations)))
+
+# locations = api.get_location_by_coordinates(53.553155, 10.006151)
+# print('Location Latitude/Longitude:\n\r{}'.format(pprint.PrettyPrinter(indent=4).pformat(locations)))
+
+# category_attributes = api.get_category_attributes(88)
+# print('Category Attributes for cat 88:\n\r{}'.format(pprint.PrettyPrinter(indent=4).pformat(category_attributes)))