@@ -7,12 +7,12 @@
77 @using-api no
88 @results HTML
99 @stable no (HTML can change)
10− @parse url, title, thumbnail, img_src, content
10+ @parse url, title, thumbnail
1111"""
1212
13−from lxml import html
13+from lxml import html, etree
1414from urllib.parse import urlencode, urljoin
15−from searx.utils import extract_text
15+from searx.utils import extract_text, eval_xpath_list, eval_xpath_getindex
1616
1717# engine dependent config
1818categories = ['images']
@@ -21,6 +21,7 @@ paging = False
2121# search-url
2222base_url = 'https://1x.com'
2323search_url = base_url + '/backend/search.php?{query}'
24+gallery_url = 'https://gallery.1x.com/'
2425
2526
2627# do search-request
@@ -33,23 +34,18 @@ def request(query, params):
3334# get response from search-request
3435def response(resp):
3536 results = []
36−
37− dom = html.fromstring(resp.text)
38− for res in dom.xpath('//div[@class="List-item MainListing"]'):
39− # processed start and end of link
40− link = res.xpath('//a')[0]
41−
37+ xmldom = etree.fromstring(resp.content)
38+ xmlsearchresult = eval_xpath_getindex(xmldom, '//searchresult', 0)
39+ dom = html.fragment_fromstring(xmlsearchresult.text, create_parent='div')
40+ for link in eval_xpath_list(dom, '/div/table/tr/td/div[2]//a'):
4241 url = urljoin(base_url, link.attrib.get('href'))
4342 title = extract_text(link)
44−
45− thumbnail_src = urljoin(base_url, res.xpath('.//img')[0].attrib['src'])
46− # TODO: get image with higher resolution
47− img_src = thumbnail_src
43+ thumbnail_src = urljoin(gallery_url, eval_xpath_getindex(link, './/img', 0).attrib['src'])
4844
4945 # append result
5046 results.append({'url': url,
5147 'title': title,
52− 'img_src': img_src,
48+ 'img_src': thumbnail_src,
5349 'content': '',
5450 'thumbnail_src': thumbnail_src,
5551 'template': 'images.html'})