on master help sign in
Merge remote-tracking branch 'asciimoo/master'
07f83caThomas Pointhuber
searx/engines/google_news.py+1−1
@@ -6,7 +6,7 @@ from json import loads
6categories = ['news']
6categories = ['news']
7
7
8url = 'https://ajax.googleapis.com/'
8url = 'https://ajax.googleapis.com/'
9−search_url = url + 'ajax/services/search/news?v=2.0&start={offset}&rsz=large&safe=off&filter=off&{query}&hl={language}' # noqa
9+search_url = url + 'ajax/services/search/news?v=2.0&start={offset}&rsz=large&safe=off&filter=off&{query}&hl={language}' # noqa
10
10
11paging = True
11paging = True
12language_support = True
12language_support = True
searx/engines/yahoo.py+1−1
@@ -35,7 +35,7 @@ def response(resp):
35
35
36 for result in dom.xpath(results_xpath):
36 for result in dom.xpath(results_xpath):
37 url_string = extract_url(result.xpath(url_xpath), search_url)
37 url_string = extract_url(result.xpath(url_xpath), search_url)
38− start = url_string.find('/RU=')+4
38+ start = url_string.find('http', url_string.find('/RU=')+1)
39 end = url_string.rfind('/RS')
39 end = url_string.rfind('/RS')
40 url = unquote(url_string[start:end])
40 url = unquote(url_string[start:end])
41 title = extract_text(result.xpath(title_xpath)[0])
41 title = extract_text(result.xpath(title_xpath)[0])
searx/engines/yahoo_news.py+1−1
@@ -35,7 +35,7 @@ def response(resp):
35
35
36 for result in dom.xpath(results_xpath):
36 for result in dom.xpath(results_xpath):
37 url_string = extract_url(result.xpath(url_xpath), search_url)
37 url_string = extract_url(result.xpath(url_xpath), search_url)
38− start = url_string.find('/RU=')+4
38+ start = url_string.find('http', url_string.find('/RU=')+1)
39 end = url_string.rfind('/RS')
39 end = url_string.rfind('/RS')
40 url = unquote(url_string[start:end])
40 url = unquote(url_string[start:end])
41 title = extract_text(result.xpath(title_xpath)[0])
41 title = extract_text(result.xpath(title_xpath)[0])
searx/utils.py+5−2
@@ -4,12 +4,15 @@ import csv
4from codecs import getincrementalencoder
4from codecs import getincrementalencoder
5import cStringIO
5import cStringIO
6import re
6import re
7+from random import choice
7
8
9+ua_versions = ('26.0', '27.0', '28.0')
10+ua_os = ('Windows NT 6.3; WOW64', 'X11; Linux x86_64; rv:26.0')
11+ua = "Mozilla/5.0 ({os}) Gecko/20100101 Firefox/{version}"
8
12
9def gen_useragent():
13def gen_useragent():
10 # TODO
14 # TODO
11− ua = "Mozilla/5.0 (X11; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0"
15+ return ua.format(os=choice(ua_os), version=choice(ua_versions))
12− return ua
13
16
14
17
15def highlight_content(content, query):
18def highlight_content(content, query):