mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-16 01:19:49 +00:00
specify encoding for scraping
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@135 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
f3fc78f8fa
commit
dc50e0c403
2 changed files with 5 additions and 5 deletions
|
@ -47,10 +47,10 @@ public final class ParserUtils
|
||||||
|
|
||||||
public static CharSequence scrape(final String url) throws IOException
|
public static CharSequence scrape(final String url) throws IOException
|
||||||
{
|
{
|
||||||
return scrape(url, null);
|
return scrape(url, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CharSequence scrape(final String url, final String request) throws IOException
|
public static CharSequence scrape(final String url, final String request, final String encoding) throws IOException
|
||||||
{
|
{
|
||||||
int tries = 3;
|
int tries = 3;
|
||||||
|
|
||||||
|
@ -70,12 +70,12 @@ public final class ParserUtils
|
||||||
|
|
||||||
if (request != null)
|
if (request != null)
|
||||||
{
|
{
|
||||||
final Writer writer = new OutputStreamWriter(connection.getOutputStream(), "ISO-8859-1");
|
final Writer writer = new OutputStreamWriter(connection.getOutputStream(), encoding != null ? encoding : "ISO-8859-1");
|
||||||
writer.write(request);
|
writer.write(request);
|
||||||
writer.close();
|
writer.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
final Reader pageReader = new InputStreamReader(connection.getInputStream(), "ISO-8859-1");
|
final Reader pageReader = new InputStreamReader(connection.getInputStream(), encoding != null ? encoding : "ISO-8859-1");
|
||||||
|
|
||||||
final char[] buf = new char[SCRAPE_INITIAL_CAPACITY];
|
final char[] buf = new char[SCRAPE_INITIAL_CAPACITY];
|
||||||
while (true)
|
while (true)
|
||||||
|
|
|
@ -121,7 +121,7 @@ public final class VbbProvider implements NetworkProvider
|
||||||
+ DATE_FORMAT.format(now) + "</DateEnd></Period><TableStation externalId='" + stationId + "'/></STBReq></ReqC>";
|
+ DATE_FORMAT.format(now) + "</DateEnd></Period><TableStation externalId='" + stationId + "'/></STBReq></ReqC>";
|
||||||
final String uri = "http://www.vbb-fahrinfo.de/hafas/extxml/extxml.exe/dn";
|
final String uri = "http://www.vbb-fahrinfo.de/hafas/extxml/extxml.exe/dn";
|
||||||
|
|
||||||
final CharSequence page = ParserUtils.scrape(uri, request);
|
final CharSequence page = ParserUtils.scrape(uri, request, null);
|
||||||
|
|
||||||
final Matcher mError = P_STATION_LOCATION_ERROR.matcher(page);
|
final Matcher mError = P_STATION_LOCATION_ERROR.matcher(page);
|
||||||
if (mError.find())
|
if (mError.find())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue