|
@@ -13,7 +13,6 @@ from cgi import escape
|
13
|
13
|
from urllib import urlencode
|
14
|
14
|
from urlparse import urlparse, parse_qsl
|
15
|
15
|
from lxml import html, etree
|
16
|
|
-from searx.poolrequests import get
|
17
|
16
|
from searx.engines.xpath import extract_text, extract_url
|
18
|
17
|
from searx.search import logger
|
19
|
18
|
|
|
@@ -91,7 +90,7 @@ url_map = 'https://www.openstreetmap.org/'\
|
91
|
90
|
search_path = '/search'
|
92
|
91
|
search_url = ('https://{hostname}' +
|
93
|
92
|
search_path +
|
94
|
|
- '?{query}&start={offset}&gbv=1')
|
|
93
|
+ '?{query}&start={offset}&gbv=1&gws_rd=cr')
|
95
|
94
|
|
96
|
95
|
# other URLs
|
97
|
96
|
map_hostname_start = 'maps.google.'
|
|
@@ -129,27 +128,6 @@ image_img_src_xpath = './img/@src'
|
129
|
128
|
property_address = "Address"
|
130
|
129
|
property_phone = "Phone number"
|
131
|
130
|
|
132
|
|
-# cookies
|
133
|
|
-pref_cookie = ''
|
134
|
|
-nid_cookie = {}
|
135
|
|
-
|
136
|
|
-
|
137
|
|
-# see https://support.google.com/websearch/answer/873?hl=en
|
138
|
|
-def get_google_pref_cookie():
|
139
|
|
- global pref_cookie
|
140
|
|
- if pref_cookie == '':
|
141
|
|
- resp = get('https://www.google.com/ncr', allow_redirects=False)
|
142
|
|
- pref_cookie = resp.cookies["PREF"]
|
143
|
|
- return pref_cookie
|
144
|
|
-
|
145
|
|
-
|
146
|
|
-def get_google_nid_cookie(google_hostname):
|
147
|
|
- global nid_cookie
|
148
|
|
- if google_hostname not in nid_cookie:
|
149
|
|
- resp = get('https://' + google_hostname)
|
150
|
|
- nid_cookie[google_hostname] = resp.cookies.get("NID", None)
|
151
|
|
- return nid_cookie[google_hostname]
|
152
|
|
-
|
153
|
131
|
|
154
|
132
|
# remove google-specific tracking-url
|
155
|
133
|
def parse_url(url_string, google_hostname):
|
|
@@ -201,12 +179,6 @@ def request(query, params):
|
201
|
179
|
|
202
|
180
|
params['headers']['Accept-Language'] = language
|
203
|
181
|
params['headers']['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
|
204
|
|
- if google_hostname == default_hostname:
|
205
|
|
- try:
|
206
|
|
- params['cookies']['PREF'] = get_google_pref_cookie()
|
207
|
|
- except:
|
208
|
|
- logger.warning('cannot fetch PREF cookie')
|
209
|
|
- params['cookies']['NID'] = get_google_nid_cookie(google_hostname)
|
210
|
182
|
|
211
|
183
|
params['google_hostname'] = google_hostname
|
212
|
184
|
|