如何从一个URL数据 [英] how to get data from a url
问题描述
我有在一个网站提供的数据,它是psented如以下图像$ P $:
i have data provided in a website and it is presented as in the following image:
本网站提供一些相关参数,更新一次,而值。 现在我想根据列名和Android应用程序的行号检索这些数据,我知道如何打开HTTP连接。 但不幸的是我不知道的我应该从哪里开始以及如何读取图像中提供的数据。
this website offers values of some parameters which are updated every while. now i want to retrieve these data according to the column name and the row number in the android APP, i know how to open http connection. but unfortunately i have no idea from where should i start and how to read the data provided in the image.
你的帮助是非常AP preciated。
your help is highly appreciated.
推荐答案
除非你有一个特殊的数据源上下工夫,一定要仔细阅读该网站的内容,然后手动处理。下面是从 Java教程,了解如何从URL连接读取的链接。
Unless you have a special data source to work on, you have to read the website's contents then process it manually. Here is a link from the java tutorials on how to read from an URL connection.
import java.net.*;
import java.io.*;
public class URLConnectionReader {
public static void main(String[] args) throws Exception {
URL oracle = new URL("http://www.oracle.com/");
URLConnection yc = oracle.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(
yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
}
编辑:
如果您是使用代理,你也应该设置这些系统属性(为适当的值):
If you are behind a proxy you should also set these system properties (to the appropriate values):
System.setProperty("http.proxyHost", "3.182.12.1");
System.setProperty("http.proxyPort", "1111");
这篇关于如何从一个URL数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!