[FIX] website: encode param for seo search, else multi words will not work.
This commit is contained in:
parent
28e62e46b5
commit
19a6e879f0
|
@ -360,8 +360,14 @@ class Website(openerp.addons.web.controllers.main.Home):
|
||||||
|
|
||||||
@http.route(['/website/seo_suggest/<keywords>'], type='http', auth="public", website=True)
|
@http.route(['/website/seo_suggest/<keywords>'], type='http', auth="public", website=True)
|
||||||
def seo_suggest(self, keywords):
|
def seo_suggest(self, keywords):
|
||||||
url = "http://google.com/complete/search?ie=utf8&oe=utf8&output=toolbar&q="
|
url = "http://google.com/complete/search"
|
||||||
req = urllib2.Request("%s?%s" % (url, keywords))
|
param = {
|
||||||
|
'ie': 'utf8',
|
||||||
|
'oe': 'utf8',
|
||||||
|
'output': 'toolbar',
|
||||||
|
'q': keywords
|
||||||
|
}
|
||||||
|
req = urllib2.Request("%s?%s" % (url, werkzeug.url_encode(param)))
|
||||||
request = urllib2.urlopen(req)
|
request = urllib2.urlopen(req)
|
||||||
xmlroot = ET.fromstring(request.read())
|
xmlroot = ET.fromstring(request.read())
|
||||||
return json.dumps([sugg[0].attrib['data'] for sugg in xmlroot if len(sugg) and sugg[0].attrib['data']])
|
return json.dumps([sugg[0].attrib['data'] for sugg in xmlroot if len(sugg) and sugg[0].attrib['data']])
|
||||||
|
|
Loading…
Reference in New Issue