Get some HTTP resource using Python urllib:
import urllib
my_url='http://diveintomark.org/xml/atom.xml'
data = urllib.urlopen(my_url).read()
print data
Same thing in Java:
public class HttpClient
{
public static void main(String[] args) throws IOException {
URL url = new URL("http://diveintomark.org/xml/atom.xml");
URLConnection con = url.openConnection();
con.connect();
HttpURLConnection httpConnex = (HttpURLConnection) con;
InputStream inputStream = httpConnex.getInputStream();
BufferedReader b = new BufferedReader(new InputStreamReader(inputStream));
String l="";
while ((l=b.readLine())!=null)
System.out.println(l);
}
}
Aucun commentaire:
Enregistrer un commentaire