-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathleechd.py
80 lines (70 loc) · 2.27 KB
/
leechd.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/python
'''
Leechd - find your stolen items
Leechd tries to find your stolen item on Ricardo, a Swiss e-shopping plattform.
Once a candidate is found, the url is printed in the console.
Author : Christoph Lauper
Version: 0.1
'''
from lxml import html
import urllib2 as urllib
import time
import threading
import datetime
''' main class '''
class Leechd():
isRunning = False
timeOut = 5
foundItems = []
# constructor
## @arg searchObject the object to be searched
## @mod none
## @ret none
def __init__(self, searchObject):
self.searchObject = searchObject
self.url = "https://www.ricardo.ch/search/index/"+ \
"?SearchId=yY2dSnIKLFW-nnvxIxWOMr&SearchOneOf="+ \
searchObject.searchSentence+ \
"&UseDescription=True&Zip="+searchObject.zipCode+ \
"&Range="+searchObject.radius+"&ar=8&AreaCountryNr="+ \
searchObject.areaCountryNr
# run
## @arg none
## @mod self.foundItems
## @ret none
def run(self):
if self.isRunning:
return
self.isRunning = True
while self.isRunning:
page = html.fromstring(urllib.urlopen(self.url).read())
links = page.xpath('//div[@class="ric-main-content"]//a/@href')
for link in links:
if link not in self.foundItems:
self.foundItems.append(link)
print "[+]" + "http://www.ricardo.ch" + link
time.sleep(self.timeOut)
# stop
## @arg none
## @mod self.isRunning
## @ret none
def stop(self):
self.isRunning = False
''' defines an object to search '''
class SearchObject():
def __init__(self, searchSentence, zipCode, radius, areaCountryNr="2"):
self.searchSentence = searchSentence
self.zipCode = zipCode
self.radius = radius
self.areaCountryNr = areaCountryNr
''' entry point '''
if __name__ == '__main__':
searchObject = SearchObject("velo%20fahrrad%20gangurru", "8400", "20")
leechd = Leechd(searchObject)
numDays = 30
thread = threading.Thread(target = leechd.run)
thread.start()
while True:
pass
leechd.stop()
thread.join()