Vorrei creare un programma che si connetta
ad una mia pagina web [es. miosito.it/file.txt]
e copi sul mio HD il file...
Il Problema e'.. Come faccio ???
(Mi servirebbe sia per Linux che per Windows)
Vorrei creare un programma che si connetta
ad una mia pagina web [es. miosito.it/file.txt]
e copi sul mio HD il file...
Il Problema e'.. Come faccio ???
(Mi servirebbe sia per Linux che per Windows)
PoWered by:
Gentoo 1.5.3 - Kernel 2.6.7
Debian Sid - Kernel 2.6.7 - Bash 3.0
Slackware current - Kernel 2.6.7
Nessuno ???
PoWered by:
Gentoo 1.5.3 - Kernel 2.6.7
Debian Sid - Kernel 2.6.7 - Bash 3.0
Slackware current - Kernel 2.6.7
io non lo so fare in C, ma ho l'alternativa in java.
Imparare è un'esperienza, tutto il resto è solo informazione. (Albert Einstein)
Prova a Inviarmelo in Java...
Se riesco lo trasformo in C...
PoWered by:
Gentoo 1.5.3 - Kernel 2.6.7
Debian Sid - Kernel 2.6.7 - Bash 3.0
Slackware current - Kernel 2.6.7
è un articolo trovato proprio su html.itcodice:import java.io.*; import java.net.MalformedURLException; import java.net.URL; public class getPage { public getPage() { } public static void main(String args[]) { String s; try { s = args[0]; } catch(ArrayIndexOutOfBoundsException arrayindexoutofboundsexception) { s = "http://www.html.it/index.asp"; System.out.println("Nessun URL definito, prendo " + s); } System.out.println("URL:" + s); boolean flag = false; URL url = null; try { url = new URL(s); } catch(MalformedURLException malformedurlexception) { System.out.println("URL errato, prendo http://www.html.it/index.asp "); flag = true; } if(flag) try { url = new URL("http://www.html.it/index.asp "); } catch(MalformedURLException malformedurlexception1) { } BufferedReader bufferedreader; try { bufferedreader = new BufferedReader(new InputStreamReader(url.openStream())); } catch(IOException ioexception) { System.out.println("Errore di apertura del file"); return; } File file = new File(".\\" + url.getFile()); FileWriter filewriter; try { filewriter = new FileWriter(file); } catch(IOException ioexception1) { return; } try { String s1; while((s1 = bufferedreader.readLine()) != null) filewriter.write(s1); filewriter.flush(); filewriter.close(); } catch(IOException ioexception2) { System.out.println("Errore di lettura."); return; } }
Imparare è un'esperienza, tutto il resto è solo informazione. (Albert Einstein)
Grazie Mille netarrow...
Cmq aspetto ancora qualcuno che sappia come
si fa' in C o C++...
Adesso pero' mi guardero' come convertire il Tuo...
Grazie ancora...
PoWered by:
Gentoo 1.5.3 - Kernel 2.6.7
Debian Sid - Kernel 2.6.7 - Bash 3.0
Slackware current - Kernel 2.6.7
:quote:
PoWered by:
Gentoo 1.5.3 - Kernel 2.6.7
Debian Sid - Kernel 2.6.7 - Bash 3.0
Slackware current - Kernel 2.6.7
Dovresti aprire una socket che si collega al server web che ospita la pagina sulla porta 80
Poi devi mandare una richiesta tramite il protocollo HTTP (se ti serve la sintassi guarda qui) e inserisci la risposta in un buffer.
Da qui togli l'header della risposta che il server ti ha mandato e quello che ti rimane è il file richiesto.
Non ho mai provato direttamente, però se riesci ad implementare tutto dovrebbe funzionare
Come concetti ci ero piu' o meno arrivato...
Ma quello che non mi riesce e' l'implementazione !
PoWered by:
Gentoo 1.5.3 - Kernel 2.6.7
Debian Sid - Kernel 2.6.7 - Bash 3.0
Slackware current - Kernel 2.6.7
Nessuno lo sa' fare in C o C++ ???
PoWered by:
Gentoo 1.5.3 - Kernel 2.6.7
Debian Sid - Kernel 2.6.7 - Bash 3.0
Slackware current - Kernel 2.6.7