Hi guys, I'm new to this site and I have a question regarding internet bots in general.
What I want to do is to use C (or php) to create a bot that will scan the internet
(perhaps log into sites, retrieve data, get links, play internet games?) on the Mac Os X.

Also, the concept of an internet bot is quite fuzzy to me right now. It seems there are two ways to implement a bot: through emulating mouse clicks and by using network functions such as cURL. Which is really used to make internet bots?

Dani AI

Generated

As and observed, there are two practical layers for a Mac bot: talk to servers directly (fast, reliable) or drive a browser / GUI (when the site needs a real renderer). For most logins, scraping and link collection the HTTP-level route is best: embed libcurl in C (handles cookies, TLS, headers, redirects, POST/GET and auth) and parse responses with a small HTML parser (libxml2 or a DOM-aware tool). (curl.se)

When the target runs significant client-side JavaScript (dynamic pages, many browser games) use a browser automation protocol instead of faking clicks. WebDriver (Selenium) drives a real browser and is far more robust; Safari ships a native driver (safaridriver) and has safeguards and an enable/authorize workflow so automation doesn’t silently compromise user security. That approach avoids brittle timing/coordinate hacks. (webkit.org)

If GUI events are truly required (desktop-only games, apps with no network API), macOS exposes Quartz Event Services so a C program can synthesize keyboard and mouse events and post them to the system. A minimal pattern (create key-down and key-up events, post them, release) looks like this:

#include <ApplicationServices/ApplicationServices.h>
#include <Carbon/Carbon.h> // kVK_ANSI_A

CGEventSourceRef src = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
CGEventRef down = CGEventCreateKeyboardEvent(src, (CGKeyCode)kVK_ANSI_A, true);
CGEventRef up   = CGEventCreateKeyboardEvent(src, (CGKeyCode)kVK_ANSI_A, false);
CGEventPost(kCGHIDEventTap, down);
CGEventPost(kCGHIDEventTap, up);
CFRelease(down); CFRelease(up); CFRelease(src);

Posting events this way is documented in community and API references; for controlling UI elements more robustly use the Accessibility/AX API (AXUIElement) rather than blind clicks. (stackoverflow.com)

Practical workflow: try HTTP (libcurl) first, fall back to WebDriver for JS-heavy sites, and use Quartz/AX only as a last resort. Note that macOS requires explicit user approval for apps that control the UI (Accessibility/Privacy settings) and tools exist to prompt for that trust; respect site terms of service and legal/ethical limits when automating. (support.apple.com)

Recommended Answers

All 2 Replies

This gives general information about bots

I am not entirely convinced if you need this information for destructive or constructive purposes so I will not give any further information. If you are really interested in this topic then google will be your best friend in this endeavor

Thanks, I have checked that out. I have googled the subject for some time and Wikipedia is my main source of reference on any subject. I have found out you may use cURL to automate logins and simulate cookies. You may also use sockets to send packets of data. On Windows, you may emulate keyboard input and mouse input to interface with Windows browsers.

I suppose all these define how a bot is made. But cURL works only with POSTS and GETS. To really make a bot do whatever you want I guess you need to emulate keyboard input and key clicks.

Is there any way to do that on a Mac OS X in C (like in Windows)?
On Windows there is a header that allows you to simulate input, but I haven't found any for the Mac.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.