-
Notifications
You must be signed in to change notification settings - Fork 1
/
baseparser.py
executable file
·62 lines (46 loc) · 1.43 KB
/
baseparser.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python
import os
import sys
from httplib2 import Http
from BeautifulSoup import BeautifulSoup as bsoup
class Parser(object):
""" the abstract crawler class! """
def __init__ (self, content):
self.pagesp = bsoup(content)
self.content = content
self.inventory = []
def get_items(self):
return None
def get_item_name(self, item):
return None
def get_item_color(self, item):
return None
def get_item_specifications(self, item):
return None
def get_item_delivery_days(self, item):
return None
def get_item_stock_status(self, item):
return None
def get_item_price(self, item):
return None
def get_item_image(self, item):
return None
def get_item_inventory(self, item):
inventory = []
try:
inventory = [
self.get_item_name(item),
self.get_item_color(item),
self.get_item_specifications(item),
self.get_item_delivery_days(item),
self.get_item_stock_status(item),
self.get_item_price(item),
self.get_item_image(item),
]
except:
pass
return inventory
def get_inventory(self, items):
for item in items:
self.inventory.append(self.get_item_inventory(item))
return self.inventory