|  | @@ -7,12 +7,12 @@
 | 
											
												
													
														|  |   @using-api   no
 |  |   @using-api   no
 | 
											
												
													
														|  |   @results     HTML
 |  |   @results     HTML
 | 
											
												
													
														|  |   @stable      no (HTML can change)
 |  |   @stable      no (HTML can change)
 | 
											
												
													
														|  | - @parse       url, title, thumbnail, img_src, content
 |  | 
 | 
											
												
													
														|  | 
 |  | + @parse       url, title, thumbnail
 | 
											
												
													
														|  |  """
 |  |  """
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -from lxml import html
 |  | 
 | 
											
												
													
														|  | 
 |  | +from lxml import html, etree
 | 
											
												
													
														|  |  from urllib.parse import urlencode, urljoin
 |  |  from urllib.parse import urlencode, urljoin
 | 
											
												
													
														|  | -from searx.utils import extract_text
 |  | 
 | 
											
												
													
														|  | 
 |  | +from searx.utils import extract_text, eval_xpath_list, eval_xpath_getindex
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  # engine dependent config
 |  |  # engine dependent config
 | 
											
												
													
														|  |  categories = ['images']
 |  |  categories = ['images']
 | 
											
										
											
												
													
														|  | @@ -21,6 +21,7 @@ paging = False
 | 
											
												
													
														|  |  # search-url
 |  |  # search-url
 | 
											
												
													
														|  |  base_url = 'https://1x.com'
 |  |  base_url = 'https://1x.com'
 | 
											
												
													
														|  |  search_url = base_url + '/backend/search.php?{query}'
 |  |  search_url = base_url + '/backend/search.php?{query}'
 | 
											
												
													
														|  | 
 |  | +gallery_url = 'https://gallery.1x.com/'
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  # do search-request
 |  |  # do search-request
 | 
											
										
											
												
													
														|  | @@ -33,23 +34,18 @@ def request(query, params):
 | 
											
												
													
														|  |  # get response from search-request
 |  |  # get response from search-request
 | 
											
												
													
														|  |  def response(resp):
 |  |  def response(resp):
 | 
											
												
													
														|  |      results = []
 |  |      results = []
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -    dom = html.fromstring(resp.text)
 |  | 
 | 
											
												
													
														|  | -    for res in dom.xpath('//div[@class="List-item MainListing"]'):
 |  | 
 | 
											
												
													
														|  | -        # processed start and end of link
 |  | 
 | 
											
												
													
														|  | -        link = res.xpath('//a')[0]
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | 
 |  | +    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'))
 |  |          url = urljoin(base_url, link.attrib.get('href'))
 | 
											
												
													
														|  |          title = extract_text(link)
 |  |          title = extract_text(link)
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        thumbnail_src = urljoin(base_url, res.xpath('.//img')[0].attrib['src'])
 |  | 
 | 
											
												
													
														|  | -        # TODO: get image with higher resolution
 |  | 
 | 
											
												
													
														|  | -        img_src = thumbnail_src
 |  | 
 | 
											
												
													
														|  | 
 |  | +        thumbnail_src = urljoin(gallery_url, eval_xpath_getindex(link, './/img', 0).attrib['src'])
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          # append result
 |  |          # append result
 | 
											
												
													
														|  |          results.append({'url': url,
 |  |          results.append({'url': url,
 | 
											
												
													
														|  |                          'title': title,
 |  |                          'title': title,
 | 
											
												
													
														|  | -                        'img_src': img_src,
 |  | 
 | 
											
												
													
														|  | 
 |  | +                        'img_src': thumbnail_src,
 | 
											
												
													
														|  |                          'content': '',
 |  |                          'content': '',
 | 
											
												
													
														|  |                          'thumbnail_src': thumbnail_src,
 |  |                          'thumbnail_src': thumbnail_src,
 | 
											
												
													
														|  |                          'template': 'images.html'})
 |  |                          'template': 'images.html'})
 |