Subversion Repositories SmartDukaan

Rev

Rev 238 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
144 ashish 1
'''
2
Created on 12-May-2010
3
 
4
@author: gaurav
5
'''
6
 
7
from elixir import *
8
 
264 ashish 9
'''
144 ashish 10
class PhoneItem(Entity):
11
    url = Field(String(1000))
12
    name = Field(String(50))
13
    price = Field(Integer)
14
    source = Field(String(100))
15
    is_crawled = Field(Boolean)
16
    phones = ManyToOne("Phones")
17
 
18
    def __repr__(self):
19
        return "%s %s" %(self.url, self.name)
20
 
21
class Phones(Entity):
22
    vendor = Field(String(100))
23
    base_url = Field(String(1000))
24
    items = OneToMany("PhoneItem")
25
 
26
class Vendor(Entity):
27
    v_name = Field(String(100))
28
    v_url = Field(String(1000))
29
 
264 ashish 30
class themobilestoreurls(Entity):
31
    url = Field(String(1000))
32
 
33
class themobilestorephones(Entity):
34
    name = Field(String(100))
35
    shown_price = Field(Integer)
36
    final_price = Field(Integer)
37
 
38
class pricesbolourls(Entity):
39
    url = Field(String(1000))
40
 
41
class pricesbolophones(Entity):
42
    name = Field(String(100))
43
    shown_price = Field(Integer)
44
    final_price = Field(Integer)
45
'''
46
 
47
"""
48
For each class crawl_id is used to retain past data for comparison, on each new crawl a new crawl_id is generated
49
"""
50
class crawl(Entity):
51
    """
52
    Documentation for class crawl
53
    It represents database table for crawl, it stores
54
    crawled_date = date of crawling
55
    On each new crawl a new entry is made
56
    Reason for creating this table is for retaining past data for comparison
57
    """
58
    crawled_date = Field(DATE(100))
59
 
144 ashish 60
class infibeam_data(Entity):
264 ashish 61
    """
62
    Documentation for class infibeam_data
63
    It represents database table for infibeam, it stores
64
    name = name of the phone
65
    shown_price = price offered by infibeam
66
    final_price = price which one has to pay, 
67
    final_price = shown_price + taxes + ship-price
68
    """
69
    crawl_id = Field(Integer)
144 ashish 70
    name = Field(String(100))
71
    shown_price = Field(Integer)
72
    final_price = Field(Integer)
150 ashish 73
 
74
class univercell_data(Entity):    
264 ashish 75
    """
76
    Documentation for class univercell_data
77
    It represents database table for univercell, it stores
78
    v_name = name of the vendor
79
    v_site = url of the vendor
80
    """
81
    crawl_id = Field(Integer)
150 ashish 82
    v_name = Field(String(100))
83
    v_site = Field(String(1000))
84
 
264 ashish 85
class univercell_items(Entity):
86
    """
87
    Documentation for class univercell_items
88
    It represents database table for univercell, it stores
89
    p_title = name of the phone
90
    p_shown_price = price offered by univercell
91
    p_final_price = price which one has to pay, 
92
    p_final_price = p_shown_price + taxes + ship-price
93
    """    
94
    crawl_id = Field(Integer)
150 ashish 95
    p_title = Field(String(100))
96
    p_shown_price = Field(Integer)
97
    p_final_price = Field(Integer)
173 ashish 98
 
264 ashish 99
class indiaplaza_data(Entity):
100
    """
101
    Documentation for class indiaplaza_data
102
    It represents database table for indiaplaza, it stores
103
    v_name = name of the vendor
104
    v_site = url of the vendor
105
    """
106
    crawl_id = Field(Integer)    
173 ashish 107
    v_name = Field(String(100))
108
    v_site = Field(String(1000))
150 ashish 109
 
173 ashish 110
class indiaplaza_items(Entity): 
264 ashish 111
    """
112
    Documentation for class indiaplaza_items
113
    It represents database table for indiaplaza, it stores
114
    p_name = name of the phone
115
    p_shown_price = price offered by indiaplaza
116
    p_final_price = price which one has to pay, 
117
    p_final_price = p_shown_price + taxes + ship-price
118
    p_guaranteeinfo = duaration of guarantee and whether guarantee is from vendor or manufacturer 
119
    p_shipinfo = how much time would be taken for shipping
120
    """
121
    crawl_id = Field(Integer)
173 ashish 122
    p_name = Field(String(100))   
123
    p_shown_price = Field(Integer)
124
    p_final_price = Field(Integer)
125
    p_guaranteeinfo = Field(String(100))
126
    p_shipinfo = Field(String(100))
127
 
128
 
238 ashish 129
class themobilestorephones_new(Entity):
264 ashish 130
    """
131
    Documentation for class themobilestorephones_new
132
    It represents database table for themobilestore, it stores
133
    name = name of the phone
134
    shown_price = price offered by themobilestore
135
    final_price = price which one has to pay, 
136
    final_price = shown_price + taxes + ship-price
137
    extra_info = whether phone can be bought or not
138
    """
139
    crawl_id = Field(Integer)
238 ashish 140
    name = Field(String(100))
141
    shown_price = Field(Integer)
142
    final_price = Field(Integer)
143
    extra_info = Field(String(1000))
144
 
173 ashish 145
class naaptolurls(Entity):
264 ashish 146
    """
147
    Documentation for class naaptolurls
148
    It represents database table for naaptol, it stores
149
    url = url of the phones, which we got from sitemap.xml
150
    """    
151
    crawl_id = Field(Integer)
173 ashish 152
    url = Field(String(1000))   
153
 
154
class morenaaptolurls(Entity):
264 ashish 155
    """
156
    Documentation for class naaptolurls
157
    It represents database table for naaptol, it stores
158
    url = url of the phones, here urls are the ones which are redirected 
159
    and contained 'price' but before storing 'price' is replaced by 'features'
160
    """
161
    crawl_id = Field(Integer)
173 ashish 162
    url = Field(String(1000)) 
163
 
264 ashish 164
class naaptolphones(Entity):
165
    """
166
    Documentation for class naaptolphones
167
    It represents database table for naaptol, it stores
168
    name = name of the phone, 
169
    range = price range for each phone
170
    range is in one of the 3 forms, i.e
171
    range = a to b
172
    range = a
173
    range = a(approx)
174
    here a,b are integers
175
    """      
176
    crawl_id = Field(Integer)
173 ashish 177
    name = Field(String(100))
178
    range = Field(String(100))
179
 
180
class ntonlinesp(Entity):
264 ashish 181
    """
182
    Documentation for class ntonlinesp
183
    It represents database table for naaptol, it stores
184
    nid = id of the phone in naaptolphones 
185
    name = name of the onlinesupplier, 
186
    price = price offered by the supplier for the phone 
187
    """
188
    crawl_id = Field(Integer)
173 ashish 189
    nid = Field(Integer)
190
    name = Field(String(100))
191
    price = Field(Integer)
192
 
193
class ntofflinesp(Entity):
264 ashish 194
    """
195
    Documentation for class ntofflinesp
196
    It represents database table for naaptol, it stores
197
    nid = id of the phone in naaptolphones 
198
    name = name of the offlinesupplier, 
199
    price = price offered by the supplier for the phone 
200
    """
201
    crawl_id = Field(Integer)
173 ashish 202
    nid = Field(Integer)
203
    name = Field(String(100))
204
    price = Field(Integer)
205
 
238 ashish 206
class babuchak_urls(Entity):
264 ashish 207
    """
208
    Documentation for class babuchak_urls
209
    It represents database table for babuchak, it stores
210
    url = url for the vendors
211
    no_pages = number of pages for individual vendor
212
    """
213
    crawl_id = Field(Integer)
238 ashish 214
    url = Field(String(100))
215
    no_pages = Field(Integer)
173 ashish 216
 
238 ashish 217
class babuchak_phoneurls(Entity):
264 ashish 218
    """
219
    Documentation for class babuchak_phoneurls
220
    It represents database table for babuchak, it stores
221
    url = url for the individual phones
222
    """
223
    crawl_id = Field(Integer)
238 ashish 224
    url = Field(String(100))
225
 
226
class babuchak_phones(Entity):
264 ashish 227
    """
228
    Documentation for class babuchak_phones
229
    It represents database table for babuchak, it stores
230
    name = name of the phone
231
    shown_price = price offered by babuchak
232
    final_price = price which one has to pay, 
233
    final_price = shown_price + taxes + ship-price
234
    """
235
    crawl_id = Field(Integer)
238 ashish 236
    name = Field(String(100))
237
    shown_price = Field(Integer)
238
    final_price = Field(Integer)
239
 
173 ashish 240
class suppliers(Entity):
264 ashish 241
    """
242
    Documentation for class suppliers
243
    It represents database table for suppliers, it stores
244
    name = name of the supplier
245
    site = url of the supplier
246
    last_crawled = date of the last run for this supplier
247
    This table spans all the suppliers in our database
248
    """
173 ashish 249
    name = Field(String(100))
250
    site = Field(String(100))
251
    last_crawled = Field(DATE(100))
252
 
253
class models(Entity):
264 ashish 254
    """
255
    Documentation for class models
256
    It represents database table for models, it stores
257
    brand = name of the brand for a particular phone
258
    model = name of the model for a particular phone
259
    This table spans all the phones-models in our database
260
    """
261
    crawl_id = Field(Integer)
173 ashish 262
    brand = Field(String(100))
263
    model = Field(String(100))
264
 
265
class prices(Entity):
264 ashish 266
    """
267
    Documentation for class prices
268
    It represents database table for prices, it stores
269
    supplier_id = id of the supplier who is selling this phone, from suppliers table
270
    mobile_id = id of the model of this phone, from models table
271
    quoted_price = price of the phone as offered by the supplier 
272
    final_price = price one has to pay to buy this phone, i.e
273
    it includes vat, tax and shippping charges
274
    extra_info = extra-info about this phone
275
    This table spans all the phones in our database
276
    """
277
    crawl_id = Field(Integer)
173 ashish 278
    supplier_id = Field(Integer)
279
    mobile_id = Field(Integer)
280
    quoted_price = Field(Integer)  
281
    final_price = Field(Integer)
282
    extra_info = Field(String(1000))
203 ashish 283
 
264 ashish 284
class guarantee_info(Entity):
285
    """
286
    Documentation for class guarantee_info
287
    It represents database table for guarantee_info, it stores
288
    mid = id of the phone in models table
289
    guaranteeinfo = duaration of guarantee and whether guarantee is from vendor or manufacturer 
290
    shipinfo = how much time would be taken for shipping.
291
    This table spans all the phones in our database
292
    """
293
    crawl_id = Field(Integer)
294
    mid = Field(Integer)
295
    guaranteeinfo = Field(String(100))
296
    shipinfo = Field(String(100))
173 ashish 297
 
264 ashish 298
class extra_vars(Entity):
299
    """
300
    Documentation for class extra_vars
301
    It represents database table for extra_vars, it stores
302
    var = name of the variable
303
    val = value of the variable
304
    desc = description of the variable
305
    For some suppliers the number of pages to be crawled is not fixed,
306
    for them variables are created and based on the value of the variable 
307
    number of the pages to be crawled is determined dynamically
308
    """
309
    var = Field(String(100))    
310
    val = Field(String(100))
311
    desc = Field(String(1000))
312
 
144 ashish 313
def init():
264 ashish 314
    """
315
    Documentation for method init
316
    Before using all the tables described in this module, one has to call this method
317
    """
173 ashish 318
    #metadata.bind = "sqlite:///phones.sqlite"
319
    metadata.bind = "mysql://root@localhost/phonecrawler"
144 ashish 320
    metadata.bind.echo = True
321
    setup_all(True)
173 ashish 322
    pass
144 ashish 323
 
324
 
325
if __name__ == "__main__":
326
   init()