diff options
| author | Adam Tauber <asciimoo@gmail.com> | 2014-12-24 20:21:38 +0100 |
|---|---|---|
| committer | Adam Tauber <asciimoo@gmail.com> | 2014-12-24 20:21:38 +0100 |
| commit | 5857141e498e80c1528ac13091ae374e807cbf75 (patch) | |
| tree | 812b506c987c6ed57210dbabb0872ba88a67b74b | |
| parent | b975418e4ce33aef530f7ad88e100d47d73e4761 (diff) | |
| parent | 10e4f6f31631fe51d16b324223525570f3e75850 (diff) | |
Merge pull request #161 from Cqoicebordel/SubtitleSeeker-engine
SubtitleSeeker Engine
| -rw-r--r-- | searx/engines/subtitleseeker.py | 64 | ||||
| -rw-r--r-- | searx/settings.yml | 7 |
2 files changed, 71 insertions, 0 deletions
diff --git a/searx/engines/subtitleseeker.py b/searx/engines/subtitleseeker.py new file mode 100644 index 000000000..48790a35c --- /dev/null +++ b/searx/engines/subtitleseeker.py @@ -0,0 +1,64 @@ +## Subtitleseeker (Video) +# +# @website http://www.subtitleseeker.com +# @provide-api no +# +# @using-api no +# @results HTML +# @stable no (HTML can change) +# @parse url, title, content + +from cgi import escape +from urllib import quote_plus +from lxml import html + +# engine dependent config +categories = ['videos'] +paging = True +language = "" + +# search-url +url = 'http://www.subtitleseeker.com/' +search_url = url+'search/TITLES/{query}&p={pageno}' + +# specific xpath variables +results_xpath = '//div[@class="boxRows"]' + + +# do search-request +def request(query, params): + params['url'] = search_url.format(query=quote_plus(query), + pageno=params['pageno']) + return params + + +# get response from search-request +def response(resp): + results = [] + + dom = html.fromstring(resp.text) + + # parse results + for result in dom.xpath(results_xpath): + link = result.xpath(".//a")[0] + href = link.attrib.get('href') + + if language is not "": + href = href + language + "/" + + title = escape(link.xpath(".//text()")[0]) + + content = result.xpath('.//div[contains(@class,"red")]//text()')[0] + content = content + " - " + content = content + html.tostring(result.xpath('.//div[contains(@class,"grey-web")]')[0], method='text') + + if result.xpath(".//span") != []: + content = content + " - (" + result.xpath(".//span//text()")[0].strip() + ")" + + # append result + results.append({'url': href, + 'title': title, + 'content': escape(content)}) + + # return results + return results diff --git a/searx/settings.yml b/searx/settings.yml index 847235b70..260b56ca8 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -131,6 +131,13 @@ engines: engine : searchcode_code shortcut : scc + - name : subtitleseeker + engine : subtitleseeker + shortcut : ss +# The language is an option. You can put any language written in english +# Examples : English, French, German, Hungarian, Chinese... +# language : English + - name : startpage engine : startpage shortcut : sp |