@@ -1,35 +1,60 @@
1+## General Files (Files)
3+# @website http://www.general-files.org
4+# @provide-api no (nothing found)
6+# @using-api no (because nothing found)
7+# @results HTML (using search portal)
8+# @stable no (HTML can change)
9+# @parse url, title, content
11+# @todo detect torrents?
1from lxml import html
13from lxml import html
15+# engine dependent config
16+categories = ['files']
4base_url = 'http://www.general-file.com'
20base_url = 'http://www.general-file.com'
5search_url = base_url + '/files-{letter}/{query}/{pageno}'
21search_url = base_url + '/files-{letter}/{query}/{pageno}'
23+# specific xpath variables
7result_xpath = '//table[@class="block-file"]'
24result_xpath = '//table[@class="block-file"]'
8title_xpath = './/h2/a//text()'
25title_xpath = './/h2/a//text()'
9url_xpath = './/h2/a/@href'
26url_xpath = './/h2/a/@href'
10content_xpath = './/p//text()'
27content_xpath = './/p//text()'
15def request(query, params):
31def request(query, params):
16 params['url'] = search_url.format(query=query,
33 params['url'] = search_url.format(query=query,
17 letter=query[0],
34 letter=query[0],
18 pageno=params['pageno'])
35 pageno=params['pageno'])
19 return params
37 return params
40+# get response from search-request
22def response(resp):
41def response(resp):
24 results = []
42 results = []
25 dom = html.fromstring(resp.text)
44 dom = html.fromstring(resp.text)
26 for result in dom.xpath(result_xpath):
47 for result in dom.xpath(result_xpath):
27 url = result.xpath(url_xpath)[0]
48 url = result.xpath(url_xpath)[0]
28 # skip fast download links
50 # skip fast download links
29 if not url.startswith('/'):
51 if not url.startswith('/'):
31 results.append({'url': base_url + url,
55 results.append({'url': base_url + url,
32 'title': ''.join(result.xpath(title_xpath)),
56 'title': ''.join(result.xpath(title_xpath)),
33 'content': ''.join(result.xpath(content_xpath))})
57 'content': ''.join(result.xpath(content_xpath))})
35 return results
60 return results