on master help sign in
Merge remote-tracking branch 'asciimoo/master'
commit07f83cab224d2ddf1f7fd8b544f2f2d6679c2416 authorThomas Pointhuber <thomas.pointhuber@gmx.at> dateTue 4 Mar 2014, 15:06 (13 years ago) parentfe35c8671c2e82
4 files changed+8−5
searx/engines/google_news.py+1−1 searx/engines/yahoo.py+1−1 searx/engines/yahoo_news.py+1−1 searx/utils.py+5−2
searx/engines/google_news.py+1−1
@@ -6,7 +6,7 @@ from json import loads
66categories = ['news']
77
88url = '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
1010
1111paging = True
1212language_support = True
searx/engines/yahoo.py+1−1
@@ -35,7 +35,7 @@ def response(resp):
3535
3636 for result in dom.xpath(results_xpath):
3737 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)
3939 end = url_string.rfind('/RS')
4040 url = unquote(url_string[start:end])
4141 title = extract_text(result.xpath(title_xpath)[0])
searx/engines/yahoo_news.py+1−1
@@ -35,7 +35,7 @@ def response(resp):
3535
3636 for result in dom.xpath(results_xpath):
3737 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)
3939 end = url_string.rfind('/RS')
4040 url = unquote(url_string[start:end])
4141 title = extract_text(result.xpath(title_xpath)[0])
searx/utils.py+5−2
@@ -4,12 +4,15 @@ import csv
44from codecs import getincrementalencoder
55import cStringIO
66import re
7+from random import choice
78
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}"
812
913def gen_useragent():
1014 # TODO
11− ua = "Mozilla/5.0 (X11; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0"
12− return ua
15+ return ua.format(os=choice(ua_os), version=choice(ua_versions))
1316
1417
1518def highlight_content(content, query):