google search bot, with java
Hello everybody,
I am being trying to make a "bot"(robot) which for a start i want to load site set the username password fields nad then log in. So i would like
1) make me a snippet(working,short example) which would load google(for example) then set java in the search field then press the search button(or activate its listener i don't know what it need) wait to load and for last get the first input's title
2)because i can't work if i don't know what i do i would like to send me the documentation link of what you use(if exists). Because i know only java an dsql if i need to learn any other language please suggest me an easy book.
3) i also want the links of the packages you used in order to do the snippet(except form the already existing in the java packages)
I have searched a little the last week in google but i haven't anything so i made this post.
thanks in advance for any answer
Best Regards,
Souperk
Ps:Sorry for the title but it was the best i could come up with.
Re: Questions for web experts
As it has been a day and 40 views without reply i think that noone hear has done something like that in the past. Now because i will continue searching i would like to know id this is possible with jarva or not. Also if someone is working on the snippet just post a reply in order to know it. Last if you haven't understand what i want just tell me to give a better explanation.
Thanks in advance and best regards,
Souperk
Re: Questions for web experts
First of all, you've listed a set of requirements, not a question. That's pretty rude, and unless you're willing to pay for results, it isn't going to get much interest. If you want help, you'll have to provide an SSCCE that demonstrates what you've tried and where you're stuck, as well as a specific technical question.
Also, you're describing a couple different solutions. Do you just want to pass information to a website, or do you actually want to automate the cursor and key presses to interact with the website directly? Either one could be possible with Java, depending on the website, but you aren't going to get much feedback by making demands.
Finally, you might want to check whether what you're doing is actually legal. Some websites disallow or discourage this type of thing. What are you actually trying to do?
Re: Questions for web experts
Well, first of all i want to apologise to everyone who read my post because i haven't realised that it could be rude and also i think it may seem more rude to you because i am not that familiar with english language(in this post i have about 10-15 words from google translate). Appart from that, after reading your post i realised that you don't know me and thus don't have any obligation to help me. So now to answer your questions i will try to write a SSCCE but i don't think i will succeed since and i don't have any idea that i have to do what is why i asked for that snippet(an other word for sscce) but i will do my best. I started making a programm which will choose the best combination of items in order to do something now i have made it and i want to log in the website and activate that combination. But this i mean that, my programm would load the website find some specific fields and set their text to something then find a specific button and activate it, all they others are pretty the same. Now i am pretty sure that it is legal problem since there are many scripts what make pretty much the same thing with some differences . Last but now least, i want again to apologise for my post.
Ps: "do you actually want to automate the cursor and key presses to interact with the website directly?" i am not sure what you mean but i think a part of it is what i want.
Thanks in advance and Best regards,
Souperk
Re: Questions for web experts
What I think you might be looking for is something like Selenium - Web Browser Automation or Welcome to HtmlUnit
I use it every day at work for automated testing of our applications. All our integration tests fire up a browser (in our case Firefox) and hits our web application and runs through a set of tests. Works pretty good. We especially test our Javascript that way.
Re: Questions for web experts
You could also check out the Robot class. I've never worked with Selenium before, but it sounds like what you want right out of the box, whereas the Robot class would take some finagling.
Re: Questions for web experts
Hello again, I made the snippet i had asked for using the HtmlUnit I think that there is a far better way to be done and i am looking for it but and this works for me.
The code
Code :
public void search()
throws FailingHttpStatusCodeException, MalformedURLException, IOException
{
//load the page
WebClient client = new WebClient();
HtmlPage webPage = (HtmlPage) client.getPage("http://www.google.com/");
//find the elements q is the name of the text field and btnG the button for submitting
HtmlForm form = webPage.getFormByName("f");
HtmlTextInput text = (HtmlTextInput) form.getInputByName("q");
HtmlSubmitInput submit = (HtmlSubmitInput) form.getInputByName("btnG");
//set java in the tex field and click the button
text.setValueAttribute("java");
HtmlPage resultPage = (HtmlPage) submit.click();
//print the result
System.out.println(resultPage.asText());
}
you will need all the lib folder from the htmlunit i think you don't need any specail knowledge of html for making something like this. But i think if you want togo ahead with a web bot you need to know some.
Last i want to apologise for replying late but i have to go school during the week.
Yours Souperk
Ps: i will edit the post's title and i will mark it as solved