12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- from cgi import escape
- from urllib import quote_plus
- from lxml import html
- from searx.languages import language_codes
- from searx.engines.xpath import extract_text
- categories = ['videos']
- paging = True
- language = ""
- url = 'http://www.subtitleseeker.com/'
- search_url = url + 'search/TITLES/{query}&p={pageno}'
- results_xpath = '//div[@class="boxRows"]'
- def request(query, params):
- params['url'] = search_url.format(query=quote_plus(query),
- pageno=params['pageno'])
- return params
- def response(resp):
- results = []
- dom = html.fromstring(resp.text)
- search_lang = ""
- if resp.search_params['language'] != 'all':
- search_lang = [lc[1]
- for lc in language_codes
- if lc[0][:2] == resp.search_params['language'].split('_')[0]][0]
-
- for result in dom.xpath(results_xpath):
- link = result.xpath(".//a")[0]
- href = link.attrib.get('href')
- if language is not "":
- href = href + language + '/'
- elif search_lang:
- href = href + search_lang + '/'
- title = escape(extract_text(link))
- content = extract_text(result.xpath('.//div[contains(@class,"red")]'))
- content = content + " - "
- text = extract_text(result.xpath('.//div[contains(@class,"grey-web")]')[0])
- content = content + text
- if result.xpath(".//span") != []:
- content = content +\
- " - (" +\
- extract_text(result.xpath(".//span")) +\
- ")"
-
- results.append({'url': href,
- 'title': title,
- 'content': escape(content)})
-
- return results
|