PDA

View Full Version : [HELP] Java HTTP Bot



OfficialJoe
05-25-2015, 03:42 PM
Dear A2S,

I saw that there where a few HTTP Bots written in java I also want to build 1 but how to start of with the HTTP Request.
Can I build a easy method for it or is there one? How should I start with building the bot? Is there someone that can give me a start?

Ryuzaki
05-25-2015, 03:44 PM
Chillivanilli or EdgarT can maybe help you

EdgarT
05-25-2015, 04:43 PM
There is no easy way to do this.
You can look into this https://a2s.in/botting/1866-unibot-complete-walkthrough.html
Or if you want to learn about http requests in C# I can find well explained ebook

Chillivanilli
05-25-2015, 04:45 PM
Dear A2S,

I saw that there where a few HTTP Bots written in java I also want to build 1 but how to start of with the HTTP Request.
Can I build a easy method for it or is there one? How should I start with building the bot? Is there someone that can give me a start?

Basicly I'm using this 2 classes for my Http requests:
Honoki | Java HTTP Wrapper (http://www.honoki.net/2011/07/java-http-wrapper/)

I edited them both a lot to fit my needs, but you can start with it. They have some disadvantages regarding cookies because the cookies are globally saved, not per domain.

12-6cloud
05-25-2015, 05:07 PM
I'm still new to screwing with http requests in java but maybe I can help you a little. (or confuse you :P)

This might be difficult to grasp if you don't already understand http requests and what they are made of. You will need some way of viewing the http requests that are being sent before you can send one in java. Download Fiddler, or some tool, or use a network analyzer in your browser. Google Chrome has one built in if you look at the Network tab of inspect element. I use an add-on for Firefox called HttpFox. I like the way it's organized. :P

I don't know how much you understand about http at the moment so here are some posts from atheus that may help you understand. (or confuse you :confused2:)
HTTP Requests (http://www.webdevtown.com/2015/04/http-very-basics.html) and GET and POST (http://www.webdevtown.com/2015/04/get-and-post-fundamentals.html)

The best way to learn is probably just to screw around with it yourself. Look at http requests with Google Chrome(inspect element -> network) and try to understand how they are structured and what everything means. Once you think you understand HTTP requests you might be able to start using java to send these yourself.

Here's a simple example on how you would send an http request in java and catch a response:

http://i.gyazo.com/d1b0e8820c136260e4643b566113f27d.png

This is a very simple example and doesn't involve sending any http headers along with it.

It might be annoying since you probably don't understand what a URLConnection object is or a BufferedReader but you just need to screw around with it and this will become very easy for you.

I hope I didn't confuse you haha :P

atheus
05-25-2015, 06:07 PM
I'm still new to screwing with http requests in java but maybe I can help you a little. (or confuse you :P)

This might be difficult to grasp if you don't already understand http requests and what they are made of. You will need some way of viewing the http requests that are being sent before you can send one in java. Download Fiddler, or some tool, or use a network analyzer in your browser. Google Chrome has one built in if you look at the Network tab of inspect element. I use an add-on for Firefox called HttpFox. I like the way it's organized. :P

I don't know how much you understand about http at the moment so here are some posts from atheus that may help you understand. (or confuse you :confused2:)
HTTP Requests (http://www.webdevtown.com/2015/04/http-very-basics.html) and GET and POST (http://www.webdevtown.com/2015/04/get-and-post-fundamentals.html)

The best way to learn is probably just to screw around with it yourself. Look at http requests with Google Chrome(inspect element -> network) and try to understand how they are structured and what everything means. Once you think you understand HTTP requests you might be able to start using java to send these yourself.

Here's a simple example on how you would send an http request in java and catch a response:

http://i.gyazo.com/d1b0e8820c136260e4643b566113f27d.png

This is a very simple example and doesn't involve sending any http headers along with it.

It might be annoying since you probably don't understand what a URLConnection object is or a BufferedReader but you just need to screw around with it and this will become very easy for you.

I hope I didn't confuse you haha :P

nice. commend yo code :)

12-6cloud
05-25-2015, 06:28 PM
nice. commend yo code :)

It's not my code xD
I stole it from the java documentation https://docs.oracle.com/javase/tutorial/networking/urls/readingWriting.html

OfficialJoe
05-25-2015, 09:06 PM
Basicly I'm using this 2 classes for my Http requests:

I edited them both a lot to fit my needs, but you can start with it. They have some disadvantages regarding cookies because the cookies are globally saved, not per domain.

But how would you invoke clicking buttons? Example your warofclicks bot.


There is no easy way to do this.
You can look into this
Or if you want to learn about http requests in C# I can find well explained ebook

I will talk to Chillivanilli about this situation in java. I hope I can contribute something ASAP also thanks for your offer in C# the only thing is I have more expierence in Java atm and for C# I need to download that heavy Visual Studio and Java is easy to run with eclipse for GUI or console

Chillivanilli
05-25-2015, 09:16 PM
But how would you invoke clicking buttons? Example your warofclicks bot.



I will talk to Chillivanilli about this situation in java. I hope I can contribute something ASAP also thanks for your offer in C# the only thing is I have more expierence in Java atm and for C# I need to download that heavy Visual Studio and Java is easy to run with eclipse for GUI or console

You just need a GUI and the bot needs to be run as a Thread. So if you click the start button in the GUI, the thread is started, if you click the stop button the thread is interrupted.

OfficialJoe
05-25-2015, 09:57 PM
You just need a GUI and the bot needs to be run as a Thread. So if you click the start button in the GUI, the thread is started, if you click the stop button the thread is interrupted.
Oke what did you use for GUI? Cause I liked that style just simple java style. But I mean I mean click buttons on the website for example on yout WOC bot clicking ads etc

Chillivanilli
05-25-2015, 10:08 PM
Oke what did you use for GUI? Cause I liked that style just simple java style. But I mean I mean click buttons on the website for example on yout WOC bot clicking ads etc

I'm using the build in GUI builder of eclipse. I think you need to read a lot of what http requests are and what they consist of. Then you should install an addon like http headers or use a program like fiddler to capture http request. Then you can try to build your own http request, for example to start a search on google.

OfficialJoe
05-26-2015, 02:35 PM
I'm using the build in GUI builder of eclipse. I think you need to read a lot of what http requests are and what they consist of. Then you should install an addon like http headers or use a program like fiddler to capture http request. Then you can try to build your own http request, for example to start a search on google.

Oke weird, cause if a open the WOC bot i got like blue buttons hit but mine gives like gray buttons, Thw windows style instead of java

Chillivanilli
05-26-2015, 02:42 PM
Oke weird, cause if a open the WOC bot i got like blue buttons hit but mine gives like gray buttons, Thw windows style instead of java

You use the build in gui builder in eclipse? There are different styles which you can use and there are also different gui builder out there with different styles. Maybe you have another default style

OfficialJoe
05-26-2015, 05:07 PM
You use the build in gui builder in eclipse? There are different styles which you can use and there are also different gui builder out there with different styles. Maybe you have another default style

Can you link to the plugin that u use? I use: Window Builder ( download(dot)eclipse (dot) org/windowbuilder/WB/release/R201406251200/4.4/ )


BTW thanks for the good help and conversation I have already something to build it is not really a bot but something ppl request around the web.

Chillivanilli
05-26-2015, 05:16 PM
Can you link to the plugin that u use? I use: Window Builder ( download(dot)eclipse (dot) org/windowbuilder/WB/release/R201406251200/4.4/ )

BTW thanks for the good help and conversation I have already something to build it is not really a bot but something ppl request around the web.

I'm also using that. No problem, if you have further questions, feel free to ask

OfficialJoe
05-26-2015, 05:37 PM
I'm also using that. No problem, if you have further questions, feel free to ask

That is weird you know there is anywher any how a style option? Cause I really want the java style thing if it is not possible so beat it but I do prefer it

Chillivanilli
05-26-2015, 05:44 PM
That is weird you know there is anywher any how a style option? Cause I really want the java style thing if it is not possible so beat it but I do prefer it

Did you select some of this? http://i.imgur.com/7WHM3PY.png
It only shows you the selected style, but doesnt show it when you export your project.

Google about LookAndFeel in java and how to set different LookAndFeels

OfficialJoe
05-26-2015, 05:46 PM
Did you select some of this?
It only shows you the selected style, but doesnt show it when you export your project.

Google about LookAndFeel in java and how to set different LookAndFeels

Oke thanks bro Ill take a look as soon Ill code the java part ill spoil that im creating a PHP 'Server' for it to make it more user friendly ;)


EDIT: Found the style and it works perfect THANKS! currently doing some GUI design and Server coding ;) Screenshot by Lightshot (http://prntscr.com/79pa58)