我正在尝试从此URL获取HTTP响应:
http://maps.google.com/maps?cid=6578389740751741251&q=a&output=json
它应该是一个JSON对象。
我是我的应用程序,我正在获取一个JSON对象,但它不是预期的...
应用开始时的响应:
while(1); {title:“a - Google Maps”,url:“/ maps?q = a \ x26ie = UTF8 \ x26hq = a \ x26hnear =”,urlViewport:false,ei:“NJr1VO62HuHCiAaQjYHgAQ”,形式:{选择: “q”,q:{q: “一”,是什么: “一”,近: “”} ...
Android上的计算机和Firefox上的Chrome响应开始于:
,而(1); {标题: “谷歌地图”,URL:“/地图CID = 6578389740751741251 \ x26q =一个\ x26ie = UTF8 \ x26hq = \ x26hnear = ...
我阅读了上面链接的toppic,并在我的代码中更改了用户代理,但它没有做任何更改: Why I am getting different HttpResponse than browser in android?
这是我的代码:
final HttpParams params = new BasicHttpParams();
HttpClientParams.setRedirecting(params, true);
HttpClientParams.setCookiePolicy(params, CookiePolicy.BROWSER_COMPATIBILITY);
DefaultHttpClient httpClient = new DefaultHttpClient(params);
httpClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT,
"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:23.0) Gecko/20131011 Firefox/23.0");
String url = "http://maps.google.com/maps?cid=6578389740751741251&q=a&output=json";
HttpGet get = new HttpGet(url);
HttpResponse response = httpClient.execute(get);
String text = EntityUtils.toString(response.getEntity());
编辑: 这是我的计算机上的JSON对象的开始(在开头剥离'while(1)'之后):
标题:“谷歌地图”,
url:“/ maps?cid = 6578389740751741251 \ x26q = a \ x26ie = UTF8 \ x26hq = \ x26hnear =”,
urlViewport:false,
ei:“H5H0VN_DDMW68wPF4ICgAQ”,
来自Android应用程序的JSON对象:
标题:“a - Google Maps”,
url:“/ maps?q = a \ x26ie = UTF8 \ x26hq = a \ x26hnear =”,
urlViewport:false,
ei:“NJr1VO62HuHCiAaQjYHgAQ”,