Re: Question about Facebook bot application

145 views
Skip to first unread message

jodder

unread,
Nov 24, 2012, 5:47:45 PM11/24/12
to jod...@googlegroups.com
Hey Yao,

thank you for trying Jodd and Jerry!

Sorry for that, we haven't updated all docs. Since 3.4.0 some packages have been moved.
In this case, jerry package is now just: jodd.jerry; so just use:

import jodd.jerry...;


instead of 

import jodd.lagarto.dom.jerry...


Please use the latest version, it's always better :)



On Saturday, November 24, 2012 10:27:06 PM UTC+1, iglory wrote:
Hi there,

I'm trying to use Jodd and Jerry in a course project. I downloaded the source file of the Facebook bot example and wanted to see the code. But after I imported the source files and the required .jar library to Eclipse, I still find errors in statements with regard to Jodd and Jerry.
The import jodd.lagarto.dom.jerry cannot be resolved
for import statement such as,
import jodd.lagarto.dom.jerry.Jerry; 
I used the latest Jodd v3.4.0 but in the introduction page, the library is v3.3.1. I'm wondering if this is the problem that causes the errors. If it is, how can I get the earlier version of Jodd?

Thanks a lot.

Best,
Yao

jodder

unread,
Nov 25, 2012, 2:32:30 AM11/25/12
to jod...@googlegroups.com
Hey Yao,

Jerry uses SLF4J for logging. You need to add at least dummy jar from SLF4J in order to have it works.

Please read this: http://jodd.org/doc/logging-jodd.html about logging.

On Sunday, November 25, 2012 1:32:44 AM UTC+1, iglory wrote:
Hi Jodder,

Thank you very much for the swift reply.

It compiles without error now. But there is error when I tried to run the FBookBot class.

Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at jodd.lagarto.LagartoParserEngine.<clinit>(LagartoParserEngine.java:22)
at jodd.jerry.Jerry$JerryParser.createLagartoDOMBuilder(Jerry.java:80)
at jodd.jerry.Jerry$JerryParser.<init>(Jerry.java:73)
at jodd.jerry.Jerry.jerry(Jerry.java:121)
at jodd.jerry.Jerry.jerry(Jerry.java:53)
at FBookBot.loginToFacebook(FBookBot.java:33)
at FBookBot.main(FBookBot.java:19)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more

I've replaced XXX in the following line with a correct Facebook login.
private final static String EMAIL = "XXX";
private final static String PASS = "XXX";

But there is error starting from this line:
Jerry doc = Jerry.jerry(response.getHtml());

I understand that this is to create a Jerry object from response.getHtml(), but I have no idea where the error is from. Could you please help me with this problem? Thank you very much!

Best,
Yao

jodder

unread,
Nov 25, 2012, 2:33:25 AM11/25/12
to jod...@googlegroups.com
It's again the same error, about missing logging library :)


On Sunday, November 25, 2012 4:26:55 AM UTC+1, iglory wrote:
Hi there,

I'm trying to learn Jodd and Jerry by running a much simplier example: the allmusic.com example on Jerry's website. But I ran into the same error with the Facebook example.

Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at jodd.lagarto.LagartoParserEngine.<clinit>(LagartoParserEngine.java:22)
at jodd.jerry.Jerry$JerryParser.createLagartoDOMBuilder(Jerry.java:80)
at jodd.jerry.Jerry$JerryParser.<init>(Jerry.java:73)
at jodd.jerry.Jerry.jerry(Jerry.java:121)
at jodd.jerry.Jerry.jerry(Jerry.java:53)
at test.main(test.java:20)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 6 more



Could you please help me re-run this simple example and see if you get the same error? If not, there must be something wrong on my side I have to figure out. Or it might be due to the tweaking codes.

Best,
Yao

On Saturday, November 24, 2012 5:47:45 PM UTC-5, jodder wrote:

jodder

unread,
Nov 25, 2012, 2:37:46 AM11/25/12
to jod...@googlegroups.com

You should be able to do that ;) There is such method in Jerry API:


Maybe something else is a problem (have you sorted out the libs problem)?
If you still have a problem, you can always send us your example project and we can tell you whats going on :)



On Sunday, November 25, 2012 4:35:58 AM UTC+1, iglory wrote:
Sorry for the consecutive messages. My problem is that I simply cannot create Jerry object by
Jerry doc=Jerry.jerry(str);

, where str is the String containg the html to be parsed.

I'm using Eclipse to run the test class.

Thank you very much for the help.

Best,
Yao

On Saturday, November 24, 2012 5:47:45 PM UTC-5, jodder wrote:

jodder

unread,
Nov 29, 2012, 1:34:00 AM11/29/12
to jod...@googlegroups.com
Awesome!

Here we don't have browsers context and javascript engine, so you can't fire javascript functions and events.
Still, you can invoke the event in real browser and then, using FireBug for example, you can see what
HTTP requests are fired to the server - and what are the request parameters. Then you can send the same
request from java, when needed, using HttpCommons (as in our facebot example) or using our own small Http client :)
Fetch the results, parse it and thats it :) Note that results may be JSON so you may use some json deserializer
library like flexjson, or the result may be the HTML code when you can use Jerry again.

You can see this practice in our facebook bot sample as well.


Hope this helps :)


On Thursday, November 29, 2012 3:00:21 AM UTC+1, iglory wrote:
Many thanks. I added the logging libraries and it's resolved.

One quick question: do you have any idea how I can mimic the action of scrolling down in the Java bot in your example? I'm trying to do something similar but found that the friend list is actually rendered in a AJAX fashion. The fetched page only contains 12 friends. That should be triggered by the scrolling event pageScroll() and then controlled by the corresponding scripts.

Thanks again.

Best,
Yao

iglory

unread,
Nov 29, 2012, 11:00:55 AM11/29/12
to jod...@googlegroups.com
Thank you very much.

Another kind of stupid question: how can I know the response is JSON? I saw it in Firebug and I think it's not HTML. 

Best,
Yao

jodder

unread,
Nov 29, 2012, 1:16:46 PM11/29/12
to jod...@googlegroups.com
There are no stupid questions :)

Just look at the response, and if it looks like JSON then it is.

While response is usually HTML or JSON, it can be anything, like javascript that will be eval() or something else.
You just have to figure out :)
Message has been deleted

iglory

unread,
Nov 29, 2012, 5:58:38 PM11/29/12
to
Hi there,

Could you please help me take a look at the response? I tried but still don't have any idea of what this is. It's from Firebug's XmtHttpRequest tab. It this XML? If so, how should I handle it? Can you suggest any good tool?

I'm sorry but I encounter server error when trying to attach the response. Please kindly find a preview below:

for (;;);{"__ar":1,"payload":null,"domops":...........

Also, could you please make this single post with the attachment private? There are quite a few information about me in it.

Best,
Yao

jodder

unread,
Nov 29, 2012, 5:58:03 PM11/29/12
to jod...@googlegroups.com
Hello, 

what you have there is a JSON string (after stripping the for(;;); prefix).

However, I don't know the meaning of it, as i don't have enough information where and how did you get it, what do you want to achieve and how facebook works;) Facebook bot example is just a simple example of using Jerry in parsing real-world html content.

You can always reach us privately on our email, but please note that we can't help much with questions that are not Jodd-related - those requires additional effort and time.


On Thursday, November 29, 2012 10:55:16 PM UTC+1, iglory wrote:
Hi there,

Could you please help me take a look at the response? I tried but still don't have any idea of what this is. It's from Firebug's XmtHttpRequest tab. It this XML? If so, how should I handle it? Can you suggest any good tool?

I'm sorry but I encounter server error when trying to attach the response. Please kindly find a preview below:

for (;;);{"__ar":1,"payload"....

Also, could you please make this single post with the attachment private? There are quite a few information about me in it.

Best,
Yao

On Thursday, November 29, 2012 1:16:46 PM UTC-5, jodder wrote:
Reply all
Reply to author
Forward
0 new messages