I am trying to use the Google Direction API service. My addresses are in Chinese, not in English. If I enter the URL directly into the browser, Google returns Chinese addresses. However, if I include the URL in a Python program, Google will translate the Chinese addresses into English.
In the following, variables a
, b
, c
, and d
are four Chinese addresses.
from urllib.parse import quote
from urllib.request import urlopen
import json
url = 'http://maps.googleapis.com/maps/api/directions/json?'
a = '台中市霧峰區吉峰東路168號'
b = '桃園機場'
c = '台中市中區自由路一段1號'
d = '台中市大里區國光路一段1號'
url = (url +
'origin=' + quote(a) +
'&destination=' + quote(b) +
'&waypoints=optimize:true|' + quote(c) + '|' + quote(d) + '&sensor=false')
print(url)
direction = urlopen(url).read().decode('utf-8')
The addresses in direction
are all translated into English addresses. How can I prevent Google from translating addresses?
You can use a parameter
language
.See documentation.