Jump to content
  • Advertisement
Sign in to follow this  
Nyap

Making a bot for a website in C++?

This topic is 663 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How could you do this? I'd prefer if the bot was hidden (as in the website isn't visible on the GUI when the bot does its thing)

Share this post


Link to post
Share on other sites
Advertisement
Well, this sounds bit dodgy.

What website and what does the bot do to the site?

Why should it be hidden?

Finally how does this relate to game development?

Share this post


Link to post
Share on other sites
Web browsers consist of:

Making HTTP requests
Executing JavaScript
Parsing and rendering HTML/CSS

A bot needs to:

Make HTTP requests
Parse HTML (sometimes)
Execute JavaScript (extremely rarely)

HTTP requests are EXTREMELY simple compared to the other parts. You can find libraries to do this for you. A bot, instead of rendering the HTML for a user, scans the HTML for the data it's interested in instead. There are libraries for parsing HTML if you need them, or you can use plain text or regular expression searches.

Share this post


Link to post
Share on other sites

OK, I admit I should have included more information

 

I want to automate the interactive online homeworks at showmyhomework.co.uk - I'm not a lazy kid, I just thought it would be an interesting project

 

I want it to be hidden so that the interface is cleaner

 

And it doesn't relate to game development, because I put it in the general programming section

Share this post


Link to post
Share on other sites

Web browsers consist of:

Making HTTP requests
Executing JavaScript
Parsing and rendering HTML/CSS

A bot needs to:

Make HTTP requests
Parse HTML (sometimes)
Execute JavaScript (extremely rarely)

HTTP requests are EXTREMELY simple compared to the other parts. You can find libraries to do this for you. A bot, instead of rendering the HTML for a user, scans the HTML for the data it's interested in instead. There are libraries for parsing HTML if you need them, or you can use plain text or regular expression searches.

Ok thanks.

Share this post


Link to post
Share on other sites
A bit more about what you'll need to understand to make a bot for modern web pages:

Interactive web pages are divided into two parts: The part that is downloaded onto your computer (HTML, CSS, javascript) and the part that runs on the web server (the language used on the server side doesn't matter to you because the two sides use a standard method of communication: HTTP).

When you've got an interactive web page, typically what happens is the javascript running on your machine makes requests to the server to transfer data, and then modifies what's being drawn in the browser GUI. Every web page is different. These are the requests that you will need to automate with your bot. In order to find out how those requests work, you will need to analyze the requests being sent. Most browsers come with a built-in set of debugging tools which will let you watch the requests being made.

After you figure out how the requests work, all you need to do is write a program which understands the possible requests that you can make, how to read the data that the server sends to you, and how to send data back to the server.

The most common type of request you'll have to deal with is logging in. Typically you send some credentials in a request, and the server responds with a session token. From then on, you make each subsequent request using that session token.

You may also need to handle cookies. Cookies are similar to session tokens: The server will occasionally give you a cookie, you need to save it on your machine somehow, and then send that cookie with each request after that.

At that point, the rest of the program is entirely up to you to decide on. Edited by Nypyren

Share this post


Link to post
Share on other sites

Google for C++ Common Gateway Interface

That will get you started.

 

You really should use Golang for this.  It's far easier to implement almost anything related to http in Golang vs C++.

Edited by fleabay

Share this post


Link to post
Share on other sites

Google for C++ Common Gateway Interface


CGI is a server mechanism, not a client mechanism. If I understand OP correctly, they want to automate interacting with an existing hosted site.

Share this post


Link to post
Share on other sites
It's pretty trivial in any framework that has good HTTP and HTML libraries. I write my web automation tools in C#, for example. I use the HtmlAgilityPack and .Net's built in Http classes. Edited by Nypyren

Share this post


Link to post
Share on other sites

 

Google for C++ Common Gateway Interface


CGI is a server mechanism, not a client mechanism. If I understand OP correctly, they want to automate interacting with an existing hosted site.

 

Oh, all I have is a hammer. Thought I saw a nail.  Stupid screws.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!