Created
May 18, 2009 16:23
-
-
Save darrinholst/113588 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void parseWebPage() { | |
String line = ""; | |
String url = ""; | |
String proto[] = { "http://", "https://" }; | |
try { | |
RandomAccessFile f = new RandomAccessFile(getAction(), "r"); | |
while ((line = f.readLine()) != null) { | |
for (int protocounter = 0; protocounter < proto.length; protocounter++) | |
if (line.contains(proto[protocounter])) { | |
try { | |
url = line.substring(line.indexOf(proto[protocounter]), line.indexOf(" ", line.indexOf(proto[protocounter]) + 1)); | |
} | |
catch (Exception e2) { | |
url = line.substring(line.indexOf(proto[protocounter])); | |
} | |
try { | |
webpage = url.substring(url.lastIndexOf("/") + 1, url.indexOf("?", url.lastIndexOf("/") + 1)); | |
} | |
catch (Exception e3) { | |
try { | |
webpage = url.substring(url.lastIndexOf("/") + 1, url.indexOf(" ", url.lastIndexOf("/") + 1)); | |
} | |
catch (Exception e4) { | |
try { | |
webpage = url.substring(url.lastIndexOf("/") + 1); | |
} | |
catch (Exception e5) { | |
webpage = "ERROR"; | |
} | |
} | |
} | |
} | |
} | |
if (webpage.charAt(webpage.length() - 1) == '"') | |
webpage = webpage.substring(0, webpage.length() - 1); | |
} | |
catch (Exception e) { | |
webpage = "ERROR"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment