-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathHttp.java
More file actions
30 lines (22 loc) · 990 Bytes
/
Http.java
File metadata and controls
30 lines (22 loc) · 990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import org.apache.http.*;
import org.apache.http.client.*;
import org.apache.http.client.fluent.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.net.URL;
import javax.imageio.ImageIO;
public class Http{
public static HttpClientDemo(String url){
String str = Request.Get(url).execute().returnContent().asString();
System.out.println(str);
}
public static HttpClientStock(String stockCode, String output){
String str = Request.Get("http://hq.sinajs.cn/list="+stockCode).execute().returnContent().asString();
System.out.println(str);
String chartType = "min"; //daily, weekly, monthly
String imageURL = "http://image.sinajs.cn/newchart/" + chartType + "/n/" + stockCode + ".gif";
BufferedImage img = ImageIO.read(new URL(imageURL));
ImageIO.write(img, "gif", new File(output));
}
}