| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 | 
""" 1x (Images)"""from lxml import html, etreefrom urllib.parse import urlencode, urljoinfrom searx.utils import extract_text, eval_xpath_list, eval_xpath_getindexabout = {    "website": 'https://1x.com/',    "wikidata_id": None,    "official_api_documentation": None,    "use_official_api": False,    "require_api_key": False,    "results": 'HTML',}categories = ['images']paging = Falsebase_url = 'https://1x.com'search_url = base_url + '/backend/search.php?{query}'gallery_url = 'https://gallery.1x.com/'def request(query, params):    params['url'] = search_url.format(query=urlencode({'q': query}))    return paramsdef response(resp):    results = []    xmldom = etree.fromstring(resp.content)    xmlsearchresult = eval_xpath_getindex(xmldom, '//searchresult', 0)    dom = html.fragment_fromstring(xmlsearchresult.text, create_parent='div')    for link in eval_xpath_list(dom, '/div/table/tr/td/div[2]//a'):        url = urljoin(base_url, link.attrib.get('href'))        title = extract_text(link)        thumbnail_src = urljoin(gallery_url, eval_xpath_getindex(link, './/img', 0).attrib['src'])                results.append({'url': url,                        'title': title,                        'img_src': thumbnail_src,                        'content': '',                        'thumbnail_src': thumbnail_src,                        'template': 'images.html'})        return results
 |