http://www.dailyfx.com.hk/xml/us_price2.xml
package com.pricetrack;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Map;
public class FxPriceClient {
public static void main(String[] args) {
FxPriceClient fpc = new FxPriceClient();
fpc.fetchData();
}
private void fetchData() {
Socket socket = null;
PrintWriter out = null;
BufferedReader in = null;
String fromServer = "";
Map currencyMap = null;
String EURUSD = null;
String USDJPY = null;
String GBPUSD = null;
String USDCHF = null;
String AUDUSD = null;
String NZDUSD = null;
String USDCAD = null;
String EURJPY = null;
String GBPJPY = null;
System.out.println(" EUR\\USD "+"\t"+" USD\\JPY "+"\t"+" GBP\\USD "+"\t"+" USD\\CHF "+"\t"+" AUD\\USD "+"\t"+" NZD\\USD "+"\t"+" USD\\CAD "+"\t"+" EUR\\JPY "+"\t"+" GBP\\JPY ");
while (1 == 1) {
try {
Thread.sleep(2000);
//socket = new Socket("webproxy.ssmb.com", 8080);
socket = new Socket("www.dailyfx.com.hk", 80);
out = new PrintWriter(socket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
out.println("GET http://www.dailyfx.com.hk/informer/fxcm_pricedde_sc.php?temp=1 ");
out.println("Host: www.dailyfx.com.hk ");
out.println("Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
out.println("Accept-Language: en-us");
out.println("Accept-Encoding: gzip,deflate");
out.println("Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7");
out.println("Keep-Alive: 300");
out.println("Proxy-Connection: keep-alive");
out.println("");
int lineNum = 0;
while ((fromServer = in.readLine()) != null) {
if (lineNum == 0) {
EURUSD = fromServer.substring(7);
} if (lineNum == 8) {
EURUSD = EURUSD + "/" + fromServer.substring(15);
} if (lineNum == 1) {
USDJPY = fromServer;
} if (lineNum == 9) {
USDJPY = USDJPY+"/"+fromServer;
} if (lineNum == 2) {
GBPUSD = fromServer;
} if (lineNum == 10) {
GBPUSD = GBPUSD+"/"+fromServer;
} if (lineNum == 3) {
USDCHF = fromServer;
} if (lineNum == 11) {
USDCHF = USDCHF+"/"+fromServer;
} if (lineNum == 4) {
AUDUSD = fromServer;
} if (lineNum == 12) {
AUDUSD = AUDUSD+"/"+fromServer;
} if (lineNum == 5) {
NZDUSD = fromServer;
} if (lineNum == 13) {
NZDUSD = NZDUSD+"/"+fromServer;
} if (lineNum == 6) {
USDCAD = fromServer;
} if (lineNum == 14) {
USDCAD = USDCAD+"/"+fromServer;
} if (lineNum == 7) {
EURJPY = fromServer;
} if (lineNum == 15) {
EURJPY = EURJPY+"/"+fromServer;
} if (lineNum == 8) {
GBPJPY = fromServer.substring(0, 6);
} if (lineNum == 16) {
GBPJPY = GBPJPY+"/"+fromServer.substring(0, 6);
}
//System.out.println(fromServer);
lineNum++;
}
System.out.println(EURUSD+"\t"+USDJPY+"\t"+GBPUSD+"\t"+USDCHF+"\t"+AUDUSD+"\t"+NZDUSD+"\t"+USDCAD+"\t"+EURJPY+"\t"+GBPJPY);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
out.close();
in.close();
socket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}