From 74b6be3991dc62577aca295de839e51e6d0807d6 Mon Sep 17 00:00:00 2001 From: asciimoo Date: Wed, 23 Oct 2013 23:55:37 +0200 Subject: [enh] engine cfg compatibilty --- searx/engines/stackoverflow.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'searx/engines/stackoverflow.py') diff --git a/searx/engines/stackoverflow.py b/searx/engines/stackoverflow.py index 26310800e..ee1a72734 100644 --- a/searx/engines/stackoverflow.py +++ b/searx/engines/stackoverflow.py @@ -5,23 +5,21 @@ from urllib import urlencode categories = ['it'] -base_url = 'http://stackoverflow.com/' -search_url = base_url+'search?' +url = 'http://stackoverflow.com/' +search_url = url+'search?' def request(query, params): - global search_url params['url'] = search_url + urlencode({'q': query}) return params def response(resp): - global base_url results = [] dom = html.fromstring(resp.text) for result in dom.xpath('//div[@class="question-summary search-result"]'): link = result.xpath('.//div[@class="result-link"]//a')[0] - url = urljoin(base_url, link.attrib.get('href')) + href = urljoin(url, link.attrib.get('href')) title = ' '.join(link.xpath('.//text()')) content = escape(' '.join(result.xpath('.//div[@class="excerpt"]//text()'))) - results.append({'url': url, 'title': title, 'content': content}) + results.append({'url': href, 'title': title, 'content': content}) return results -- cgit v1.2.3