Posting/clicking buttons java - java

i have some basic knowledge of java (made little programs to help everyday life) Now the thing is i want to make a program that posts offers on a site every 2-3 minutes. I have never done anything with java related to the internet and web pages and even after browsing the internet i am clueless. How would i go about setting up a connection to a certain page click a certain button on that page and then fill in 3 boxes with information and post the offer?
Here is what i have to click:
Here is the form i have to fill in:

You have to learn a bit more about how HTML form works, but basically browser sends a POST request to the webserver with the values from the form.
Chrome's Developer Tools, Firefox's web developer toolbar has a functionality what can help you to discover what request is sent to the server when you post a single form. Of course you have to fill the values with your heart content
If you already know what content you want to send, you can post it relative easily, it is described well with examples in this StackOverflow answer https://stackoverflow.com/a/4206094/182474.
But I strongly recommend to discover how browsers works internally from the aspect of HTTP protocol, because it is a very useful knowledge if you want to develop tools that interacts with web APIs or simulate posting HTML forms.

You could use java.awt.Robot class and make all this thinks =)
you only need to write your manually action to the automated action =)
move mouse on text
write this...
tab
write this other..
tab press enter
wait N second
hope it helps! =)

Related

Dynamically and in real time update web page contents

I need to create a screen that is automatically updated every minute or so with fresh data from a server-based data source, perhaps a simple text file or XML - and is displayed as a web page.
The screen will show a list of items that can be marked with a red, yellow or green icon, as to indicate their status. Each item has a drop-down where you can select/change the current status. So, when a user changes the status for one of the items, every screen monitoring this web page will be automatically updated.
I'm a pretty novice web programmer (I only have experience with desktop programming, VB and a little C#), so I'm really just hoping for a quick push in the right direction here. I assume that this really isn't all that difficult to implement. Am I wrong? And where can I find more info on how to do this? :-)
I really appreciate any help I can get. Thanks in advance!
This sounds like a solution with Websockets. You don't need update every minute. You're able to update every times when a user make changes. Client Side in Java Script is very easily to implement Websockets. Tutorial can be found here.
Server side you need a Websocket Server. What you need depends on which programm language you use.

Submit a review(data) through android app on a url

I want to add a functionality in my app which submits a review of a place on the place's google plus account ..
As you might be knowing the format of the google plus page ..
It has a button "Write a review" (Which is not a button but a clickable 'div')
On pressing this button , a dialogue appears which has a field to write review , It is here i want to actually write the review through the code and press the submit button .
Please help me through this ..
How to achieve this thing ??
Jsoup parses HTML. It does not execute JavaScript or emulate a browser, so there's no dialog box for it to interact with.
You could try using a browser's network monitor feature (part of their developer tools) to see what requests are made when the dialog box is submitted, then simulate those requests from your application. You could also see if there's a Google+ API for submitting reviews other than from the place's Google+ page. APIs are easier to use, robust against changes in the web page's HTML, and don't risk violating terms of service that prohibit automation. Finally, you could try a browser automation tool (commonly used for unit testing web pages); I don't know of any for Android but I'd be surprised if there aren't any.

How does Java interact with buttons on http webpage?

I have little knowledge about web programming, and I was looking through a lot of examples which gives alot of examples about writing on the webpage for web browser to see, but nothing about getting request when user presses a button the webpage.
For example, upon opening the server, it opens the port 80, then I want to go to web browser and type "localhost:80" to access the webpage made by the server client. The webpage has a button which when I click it, webpage changes to something else like "Clicked!".
Can someone show me an example code of this? Link to an example would be great as well.
Thank you very much.
I would recommend using something like Apache's HttpClient to imitate a button press, which is just an HTTP POST. And if you don't want to use a third-party library, the standard Java library already rolls its own.

How to screen scrape an Ajax site in Java?

I wish to screen scrape several Ajax based websites and simulate clicks which refresh part of the webpage, and then read the updated HTML. Is there any Java library which can do this?
Use HtmlUnit it's great for this!! It is a headless browser and has the ability to play with clicks, mouse positions and pretty much everything you would want.
I think the only way to do this is to embed a browser so that the Javascript is executed and grab the data when the DOM is updated. This related stack overflow question may help.
These books should help you (although only the first one is intended to Java developers):
Programming Spiders, Bots, and Aggregators in Java;
Webbots, Spiders, and Screen Scrapers;
Spidering Hacks;

Online Screen Capture/Recording

I would like to implement a screen recording function for the users of my website.
This will be for a penny auction style website so that the users can record their bids and provide proof if something goes wrong with the auctions.
Here is a demo of an online recorder. http://www.screentoaster.com/watch/demo/screentoaster
Does anyone know of any framework, script or third party that has these functions?
I would ultimately like to embed a record button into the auction and it would automatically start recording a predefined area.
I know this does not directly answer your question, but if I were approaching the issue of proof of purchase I would create a simple server side script for sending a confirmation email/invoice because they can be relied upon in a court of law (ISPs can prove they were sent).
The issue with the screen grabbing approach is that someone could say open developer tools in chrome, edit your webpage to look like he or she has placed a bid before pressing the screen record button.
Hope this helps!
I've had good luck with: screenr.com

Categories