on master help sign in
update generalfile engine and add comments
commitc5d83059d537d8efb296ffbe743828a884ac4e10 authorThomas Pointhuber <thomas.pointhuber@gmx.at> dateTue 2 Sep 2014, 17:28 (12 years ago) parent80b9312
2 files changed+28−4
searx/engines/generalfile.py+28−3 searx/settings.yml−1
searx/engines/generalfile.py+28−3
@@ -1,35 +1,60 @@
1+## General Files (Files)
2+#
3+# @website http://www.general-files.org
4+# @provide-api no (nothing found)
5+#
6+# @using-api no (because nothing found)
7+# @results HTML (using search portal)
8+# @stable no (HTML can change)
9+# @parse url, title, content
10+#
11+# @todo detect torrents?
12+
113from lxml import html
214
15+# engine dependent config
16+categories = ['files']
17+paging = True
318
19+# search-url
420base_url = 'http://www.general-file.com'
521search_url = base_url + '/files-{letter}/{query}/{pageno}'
622
23+# specific xpath variables
724result_xpath = '//table[@class="block-file"]'
825title_xpath = './/h2/a//text()'
926url_xpath = './/h2/a/@href'
1027content_xpath = './/p//text()'
1128
12−paging = True
13−
1429
30+# do search-request
1531def request(query, params):
32+
1633 params['url'] = search_url.format(query=query,
1734 letter=query[0],
1835 pageno=params['pageno'])
36+
1937 return params
2038
2139
40+# get response from search-request
2241def response(resp):
23−
2442 results = []
43+
2544 dom = html.fromstring(resp.text)
45+
46+ # parse results
2647 for result in dom.xpath(result_xpath):
2748 url = result.xpath(url_xpath)[0]
49+
2850 # skip fast download links
2951 if not url.startswith('/'):
3052 continue
53+
54+ # append result
3155 results.append({'url': base_url + url,
3256 'title': ''.join(result.xpath(title_xpath)),
3357 'content': ''.join(result.xpath(content_xpath))})
3458
59+ # return results
3560 return results
searx/settings.yml−1
@@ -62,7 +62,6 @@ engines:
6262
6363 - name : general-file
6464 engine : generalfile
65− categories : files
6665 shortcut : gf
6766
6867 - name : github