My goal is to connect to the OWA page (Microsoft Office Outlook Web Access - basically an email client) and log in, then read the new page and find the number of incoming mailboxes.
To enter the system I need to fill in the username and password fields and call a specific javascript function, for which I know the name and title.
Like me:
- Get DOM for page?
- Refresh DOM to fill in the entered text fields?
- Call this Javascript function?
- Get a new URL for the page I'm redirected to?
So far, I can connect to the web page and load its page source using the following Java code:
callback.status("Opening connection...");
URLConnection connection = null;
try
{
connection = url.openConnection();
}
catch(IOException ex)
{
throw new Exception("I/O Problem while attempting URL connection");
}
connection.setDoInput(true);
callback.status("Opening data stream...");
InputStream input = null;
try
{
input = connection.getInputStream();
}
catch(IOException ex)
{
throw new Exception("I/O Problem while opening data stream");
}
callback.status("Reading site...");
String content = "";
byte[] buffer = new byte[100];
int totalBytesRead = 0;
int bytesRead = 0;
try
{
while((bytesRead = input.read(buffer)) != -1)
{
String newContent = new String(buffer, 0, bytesRead);
content += newContent;
}
}
catch(IOException ex)
{
throw new Exception("I/O Problem while reading website");
}
System.out.println(content);
- .
, DOM, , :
XMLParserConfiguration config = new XML11DTDConfiguration();
DOMParser parser = new DOMParser(config);
InputSource inputSource = new InputSource(input);
inputSource.setByteStream(input);
try
{
parser.parse(inputSource);
}
catch(SAXParseException ex)
{
}
Document document = parser.getDocument();
visitNode(document, 0);
SAXParseException:: 6: 62: publicId systemId .
, :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
DOMParser -, "" .