Controlling Internet Explorer from Java

P

Paul Battersby

Can anyone point me in the direction of information on how to control
Internet Explorer from Java?

From Java, I want to tell Internet Explorer to load a page from a given Url
(this I can already do) and then have my Java Program read the HTML that is
being displayed by Internet Explorer.

Is there some DDE interface or some other way I can issue commands and get
results back from
Internet Explorer?

Thanks,
 
A

Andrew Thompson

Can anyone point me in the direction of information on how to control
Internet Explorer from Java?

Javascript - LiveConnect - Applet - Socket.

JS communicates via LiveConnect with the (signed) Applet,
which then communicates with the application via socket.

( This route has a large learning curve. )
 
A

Andrew Thompson

Can anyone point me in the direction of information on how to control
Internet Explorer ..

As an aside. That is a bit tricky - if the end user
browses the net using Safari..
 
R

Roedy Green

Can anyone point me in the direction of information on how to control
Internet Explorer from Java?

From Java, I want to tell Internet Explorer to load a page from a given Url
(this I can already do) and then have my Java Program read the HTML that is
being displayed by Internet Explorer.

Perhaps what would be much easier is to get IE out the picture, and
just pretend to be a browser yourself and send off a CGI get,
retrieving the HTML. Then extract what you want from it using a
parser.
See http://mindprod.com/jgloss/parser.html
http://mindprod.com/jgloss/cgi.html


If you actually want to see the bits that IE renders, look at the
Robots class. (sp?) to do a screen snapshot.



--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 
P

Paul Battersby

The problem I'm having is that I want to automatically download some HTML
from a web site but the remote server seems to deny my request when it comes
from a Java program but allows me to see the data when I access the web site
with Internet Explorer. My program works fine with other web sites, just not
this one in particular.

Any ideas?
 
R

Roland

The problem I'm having is that I want to automatically download some HTML
from a web site but the remote server seems to deny my request when it comes
from a Java program but allows me to see the data when I access the web site
with Internet Explorer. My program works fine with other web sites, just not
this one in particular.

Any ideas?
Probably that website checks the "User-Agent" header of the HTTP request.
You could try to set the property "http.agent" to a value that matches
Internet Explorer or another well known browser. Java uses the value of
this property when it sends a HTTP request (i.e. probably when using a
HTTPURLConnection). See
<http://java.sun.com/j2se/1.5.0/docs/guide/net/properties.html>

You can specify the value of "http.agent" either at the commandline, like

java "-Dhttp.agent=Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
your.app.Main

or in your program:

// IE6/W2K
System.setProperty("http.agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");

// Moz 1.7.8/W2K
System.setProperty("http.agent",
"Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.8)
Gecko/20050511");


--
Regards,

Roland de Ruiter
` ___ ___
`/__/ w_/ /__/
/ \ /_/ / \
 
W

Wibble

Roland said:
Probably that website checks the "User-Agent" header of the HTTP request.
You could try to set the property "http.agent" to a value that matches
Internet Explorer or another well known browser. Java uses the value of
this property when it sends a HTTP request (i.e. probably when using a
HTTPURLConnection). See
<http://java.sun.com/j2se/1.5.0/docs/guide/net/properties.html>

You can specify the value of "http.agent" either at the commandline, like

java "-Dhttp.agent=Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
your.app.Main

or in your program:

// IE6/W2K
System.setProperty("http.agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");

// Moz 1.7.8/W2K
System.setProperty("http.agent",
"Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.8)
Gecko/20050511");
The site may have activeX controls that java will never understand.
Jacob is a Java/Com interface that will let you control explorer. It
should do what you want.

http://sourceforge.net/projects/jacob-project/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top