mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-18 08:19:51 +00:00
VBB can determine location of station
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@43 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
6af2a24deb
commit
7edf771289
2 changed files with 66 additions and 1 deletions
|
@ -19,8 +19,10 @@ package de.schildbach.pte;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.Writer;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
|
@ -41,10 +43,25 @@ public final class ParserUtils
|
|||
private static final int SCRAPE_INITIAL_CAPACITY = 4096;
|
||||
|
||||
public static CharSequence scrape(final String url) throws IOException
|
||||
{
|
||||
return scrape(url, null);
|
||||
}
|
||||
|
||||
public static CharSequence scrape(final String url, final String request) throws IOException
|
||||
{
|
||||
final StringBuilder buffer = new StringBuilder(SCRAPE_INITIAL_CAPACITY);
|
||||
final URLConnection connection = new URL(url).openConnection();
|
||||
connection.setDoInput(true);
|
||||
connection.setDoOutput(request != null);
|
||||
connection.addRequestProperty("User-Agent", SCRAPE_USER_AGENT);
|
||||
|
||||
if (request != null)
|
||||
{
|
||||
final Writer writer = new OutputStreamWriter(connection.getOutputStream(), "ISO-8859-1");
|
||||
writer.write(request);
|
||||
writer.close();
|
||||
}
|
||||
|
||||
final Reader pageReader = new InputStreamReader(connection.getInputStream(), "ISO-8859-1");
|
||||
|
||||
final char[] buf = new char[SCRAPE_INITIAL_CAPACITY];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue