@@ -0,0 +1,81 @@
3+# @website http://1x.com/
8+# @stable no (HTML can change)
9+# @parse url, title, thumbnail, img_src, content
12+from urllib import urlencode
13+from urlparse import urljoin
18+# engine dependent config
19+categories = ['images']
23+base_url = 'http://1x.com'
24+search_url = base_url+'/backend/search.php?{query}'
28+def request(query, params):
29+ params['url'] = search_url.format(query=urlencode({'q': query}))
34+# get response from search-request
38+ # get links from result-text
39+ results_parts = re.split(r'(</a>|<a)', resp.text)
43+ # iterate over link parts
44+ for result_part in results_parts:
45+ # processed start and end of link
46+ if result_part == '<a':
47+ cur_element = result_part
49+ elif result_part != '</a>':
50+ cur_element += result_part
53+ cur_element += result_part
56+ cur_element = string.replace(cur_element, '"></a>', '"/></a>')
58+ dom = html.fromstring(cur_element)
59+ link = dom.xpath('//a')[0]
61+ url = urljoin(base_url, link.attrib.get('href'))
62+ title = link.attrib.get('title', '')
64+ thumbnail_src = urljoin(base_url, link.xpath('.//img')[0].attrib['src'])
65+ # TODO: get image with higher resolution
66+ img_src = thumbnail_src
68+ # check if url is showing to a photo
69+ if '/photo/' not in url:
73+ results.append({'url': url,
77+ 'thumbnail_src': thumbnail_src,
78+ 'template': 'images.html'})