0
我想在某些使用java的網站上發出GET AJAX請求。在Java中的AJAX GET請求
我的代碼如下:
String cookie = getRandomString(16); //Getting a random 32-symbol string
String url = "https://e-kassa.org/core/ajax/stations_search.php?"
+ "q=%D0%BE&limit=10×tamp=1352028872503";
HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
conn.setRequestProperty("Cookie", "PHPSESSID=" + cookie);
InputStream is = conn.getInputStream();
int buffer;
while((buffer = is.read()) != -1)
System.out.print(buffer);
is.close();
conn.disconnect();
但問題是,有什麼可從InputStream下載。但是,如果我用我的瀏覽器做同樣的事情,我會得到迴應,以下格式的文本行組成:
CITY_NAME | SOME_DIGITS
那麼,有誰能夠告訴我,我怎樣才能以適當的方式提出這樣的要求?
UPD:沒有cookie我有相同的行爲(在瀏覽器中一切正常,但沒有在Java中)。
仍然是相同的結果。其實,這裏沒有例外。 – Angstrem