diff options
| author | asciimoo <asciimoo@gmail.com> | 2013-10-23 23:55:37 +0200 |
|---|---|---|
| committer | asciimoo <asciimoo@gmail.com> | 2013-10-23 23:55:37 +0200 |
| commit | 74b6be3991dc62577aca295de839e51e6d0807d6 (patch) | |
| tree | 5bf5df160e765dc7dc6897e640fd23a761df1d2e /searx/engines/stackoverflow.py | |
| parent | 39d229e1104dc10c7c7f00380c02d46118e3d895 (diff) | |
[enh] engine cfg compatibilty
Diffstat (limited to 'searx/engines/stackoverflow.py')
| -rw-r--r-- | searx/engines/stackoverflow.py | 10 |
1 files changed, 4 insertions, 6 deletions
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 |