i reply for those who send me a private message,
this is the SWT code that worked for me :
System.setProperty("org.eclipse.swt.browser.XULRunnerPath", "/
usr/lib/xulrunner");
boolean working = false;
Display display = new Display();
final Shell shell = new Shell(display);
shell.setBounds(10,10, 500, 500);
Browser browser = new Browser(shell, SWT.MOZILLA);
browser.setBounds(10,10, 500,500);
ProgressAdapter adapter = (ProgressAdapter)new Sas(browser);
browser.addProgressListener(adapter);
System.out.println(System.currentTimeMillis());
browser.setUrl("http://www.google.com");
this code works with SWT (jar is downloadable form eclipse.org, so you
can include both netbeans and eclipse)
the jars to include are :
- swt.jar
- javaxpcom.jar
- MozillaInterfaces.jar
for AWT there is a non-free project ->
http://www.teamdev.com/jxbrowser/index.jsf
you have to purchase the license, i don't remember how much it
costs... but there is a month for trial
---------- Forwarded message ----------
From: Marco Paviotti <[EMAIL PROTECTED]>
Date: Dec 9 2007, 1:28 pm
Subject: setting urls and manage forms
To: mozilla.dev.embedding
Hi all,
my problem is : i'm developing a crawler-like application,
until now, i've used a raw http connection for retrieving html that i
want to parse.
but now i need to send the POST data to retrieve the html of a site
that make eccessive use of javascript,
so i've considered to use JavaXPCOM to emded mozilla or firefox or
gecko, for compile the form and retrieve the html generated also from
javascript.
Now i've googled and googled... but nothing, i've found only about
embedding mozilla in a GUI (SWT).
Is there a way to do this without embedding also the GUI ? I'm using
Netbeans, so i can't use SWT (AWT seems that not already implemented)
I've tried with this code, but it gets me :
org.mozilla.xpcom.XPCOMException: The function "loadURI" returned an
error condition (0x8000ffff)
at
org.mozilla.xpcom.internal.XPCOMJavaProxy.callXPCOMMethod(Native
Method)
at
org.mozilla.xpcom.internal.XPCOMJavaProxy.invoke(XPCOMJavaProxy.java:
143)
at $Proxy2.loadURI(Unknown Source)
at embedmozilla.Main.main(Main.java:55)
public static void main(String[] args) {
Mozilla mozilla = Mozilla.getInstance();
GREVersionRange[] range = new GREVersionRange[1];
range[0] = new GREVersionRange("1.8.0", true, "1.9",
false);
// work with trunk nightly version 1.9a1 ^^
try {
File grePath = Mozilla.getGREPathWithProperties(range,
null);
LocationProvider locProvider = new
LocationProvider(grePath);
mozilla.initialize(grePath);
mozilla.initEmbedding(grePath, grePath, locProvider);
System.out.println("Initted embedding");
nsIComponentManager componentManager =
mozilla.getComponentManager();
nsIWebBrowser browser = (nsIWebBrowser)
componentManager.createInstanceByContractID("@mozilla.org/embedding/
browser/nsWebBrowser;1",
null, nsIWebBrowser.NS_IWEBBROWSER_IID);
/*------->*/
nsIWebNavigation webNavigation = (nsIWebNavigation)
browser.queryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID);
webNavigation.loadURI("www.debian.org",
nsIWebNavigation.LOAD_FLAGS_NONE, null, null, null);
nsIDOMDocument document = webNavigation.getDocument();
System.out.println(document);
browser.getContentDOMWindow().getDocument();
System.out.println("Terminating embedding");
mozilla.termEmbedding();
} catch (FileNotFoundException e) {
e.printStackTrace();
// this exception is thrown if
//greGREPathWithProperties cannot find a GRE
} catch (XPCOMException e) {
e.printStackTrace();
// this exception is thrown if initEmbedding failed
}
}
Any advice ?
Thanks to all!
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding