Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: Questions for web experts

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Location
    Greece
    Posts
    14
    My Mood
    Cheerful
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default 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.
    Last edited by Souperk; March 26th, 2012 at 07:45 AM.


  2. #2
    Junior Member
    Join Date
    Nov 2011
    Location
    Greece
    Posts
    14
    My Mood
    Cheerful
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default 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

  3. #3
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default 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?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  4. The Following User Says Thank You to KevinWorkman For This Useful Post:

    Tjstretch (March 15th, 2012)

  5. #4
    Junior Member
    Join Date
    Nov 2011
    Location
    Greece
    Posts
    14
    My Mood
    Cheerful
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default 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

  6. #5
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default 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.

  7. The Following User Says Thank You to Json For This Useful Post:

    KevinWorkman (March 15th, 2012)

  8. #6
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default 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.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  9. #7
    Junior Member
    Join Date
    Nov 2011
    Location
    Greece
    Posts
    14
    My Mood
    Cheerful
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default 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
    	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

Similar Threads

  1. Needs experts help and advice
    By Addo kofi in forum JavaServer Pages: JSP & JSTL
    Replies: 3
    Last Post: June 29th, 2011, 08:44 PM
  2. Replies: 1
    Last Post: March 17th, 2011, 04:12 AM
  3. hi my dear experts
    By khamis50 in forum Object Oriented Programming
    Replies: 2
    Last Post: March 1st, 2011, 09:57 AM
  4. hello java experts
    By bidex in forum Member Introductions
    Replies: 2
    Last Post: August 23rd, 2010, 05:52 AM