Web scraping: Difference between revisions
→{{header|Java}}
m (→{{header|Phix}}: skip site notice) |
|||
Line 1,032:
=={{header|Java}}==
<syntaxhighlight lang="java">import java.io.BufferedReader;▼
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
▲import java.net.URLConnection;
public final class WebTime{
public static void main(String[]
try {
URI uri = new URI("https://www.rosettacode.org/wiki/Talk:Web_scraping").parseServerAuthority();
HttpURLConnection connection = (HttpURLConnection) address.openConnection();
BufferedReader reader = new BufferedReader( new InputStreamReader(
final int responseCode = connection.getResponseCode();
while(!(line = in.readLine()).contains("UTC"));▼
System.out.println(
}catch(IOException e){▼
String line;
System.err.println("error connecting to server.");▼
/* Empty block */
}▼
}
▲}</syntaxhighlight>
final int index = line.indexOf("UTC");
System.out.println(line.substring(index - 16, index + 4));
reader.close();
connection.disconnect();
} catch (URISyntaxException use) {
System.err.println("Unable to connect to URI: " + use.getCause());
}
}
}
</syntaxhighlight>
{{ out }}
<pre>
Response code: 200
25 August 2022 (UTC)
</pre>
=={{header|JavaScript}}==
|