Controlling Internet Explorer from Java

Discussion in 'Java' started by Paul Battersby, Jun 25, 2005.

  1. 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,
     
    Paul Battersby, Jun 25, 2005
    #1
    1. Advertisements

  2. 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. )
     
    Andrew Thompson, Jun 26, 2005
    #2
    1. Advertisements

  3. As an aside. That is a bit tricky - if the end user
    browses the net using Safari..
     
    Andrew Thompson, Jun 26, 2005
    #3
  4. Paul Battersby

    Roedy Green Guest

    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
     
    Roedy Green, Jun 26, 2005
    #4
  5. 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?
     
    Paul Battersby, Jun 26, 2005
    #5
  6. Paul Battersby

    Roland Guest

    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_/ /__/
    / \ /_/ / \
     
    Roland, Jun 26, 2005
    #6
  7. Paul Battersby

    Wibble Guest

    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/
     
    Wibble, Jun 27, 2005
    #7
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.