@@ -0,0 +1,73 @@
2+from urllib import urlencode
3+from searx.utils import html_to_text
4+from HTMLParser import HTMLParser
6+url = 'http://www.filecrop.com/'
7+search_url = url + '/search.php?w={query}&size_i=0&size_f=100000000&engine_r=1&engine_d=1&engine_e=1&engine_4=1&engine_m=1'
9+class FilecropResultParser(HTMLParser):
11+ HTMLParser.__init__(self)
12+ self.__start_processing = False
18+ self.data_counter = 0
20+ def handle_starttag(self, tag, attrs):
23+ if ('bgcolor', '#edeff5') in attrs or ('bgcolor', '#ffffff') in attrs:
24+ self.__start_processing = True
26+ if not self.__start_processing:
30+ self.result['title'] = [attr[1] for attr in attrs if attr[0] == 'title'][0]
31+ elif tag == 'a' and ('rel', 'nofollow') in attrs and ('class', 'sourcelink') in attrs:
32+ if 'content' in self.result:
33+ self.result['content'] += [attr[1] for attr in attrs if attr[0] == 'title'][0]
35+ self.result['content'] = [attr[1] for attr in attrs if attr[0] == 'title'][0]
36+ self.result['content'] += ' '
38+ self.result['url'] = url + [attr[1] for attr in attrs if attr[0] == 'href'][0]
40+ def handle_endtag(self, tag):
41+ if self.__start_processing is False:
47+ if self.tr_counter == 2:
48+ self.__start_processing = False
50+ self.data_counter = 0
51+ self.results.append(self.result)
54+ def handle_data(self, data):
55+ if not self.__start_processing:
58+ if 'content' in self.result:
59+ self.result['content'] += data + ' '
61+ self.result['content'] = data + ' '
63+ self.data_counter += 1
65+def request(query, params):
66+ params['url'] = search_url.format(query=urlencode({'q': query}))
70+ parser = FilecropResultParser()
71+ parser.feed(resp.text)
73+ return parser.results