Przeglądaj źródła

Merge remote-tracking branch 'asciimoo/master'

Thomas Pointhuber 11 lat temu
rodzic
commit
07f83cab22

+ 1
- 1
searx/engines/google_news.py Wyświetl plik

@@ -6,7 +6,7 @@ from json import loads
6 6
 categories = ['news']
7 7
 
8 8
 url = '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
 
11 11
 paging = True
12 12
 language_support = True

+ 1
- 1
searx/engines/yahoo.py Wyświetl plik

@@ -35,7 +35,7 @@ def response(resp):
35 35
 
36 36
     for result in dom.xpath(results_xpath):
37 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 39
         end = url_string.rfind('/RS')
40 40
         url = unquote(url_string[start:end])
41 41
         title = extract_text(result.xpath(title_xpath)[0])

+ 1
- 1
searx/engines/yahoo_news.py Wyświetl plik

@@ -35,7 +35,7 @@ def response(resp):
35 35
 
36 36
     for result in dom.xpath(results_xpath):
37 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 39
         end = url_string.rfind('/RS')
40 40
         url = unquote(url_string[start:end])
41 41
         title = extract_text(result.xpath(title_xpath)[0])

+ 5
- 2
searx/utils.py Wyświetl plik

@@ -4,12 +4,15 @@ import csv
4 4
 from codecs import getincrementalencoder
5 5
 import cStringIO
6 6
 import 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
 
9 13
 def gen_useragent():
10 14
     # 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))
13 16
 
14 17
 
15 18
 def highlight_content(content, query):