code a c++ script to a "tiktok scrapper bot"
- User
code a c++ script to a "tiktok scrapper bot"
Assistant
Here is a basic C++ script for a TikTok scrapper bot:
#include <iostream> #include <curl/curl.h> #include <json/json.h> using namespace std; string getTikTokVideo(string username) { CURL *curl; CURLcode res; string readBuffer; curl = curl_easy_init(); if(curl) { string url = "https://www.tiktok.com/@" + username; curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer); res = curl_easy_perform(curl); curl_easy_cleanup(curl); if(res != CURLE_OK) { cerr << "Error: " << curl_easy_strerror(res) << endl; return ""; } } Json::Value root; Json::Reader reader; bool parsingSuccessful = reader.parse( readBuffer, root ); if ( !parsingSuccessful ) { cerr << "Failed to parse JSON" << endl; return ""; } string videoUrl = root["props"]["pageProps"]["seoProps"]["metaParams"]["videoInfo"]["urls"][0].asString(); return videoUrl; } int main() { string username = "charlidamelio"; string videoUrl = getTikTokVideo(username); cout << "Video URL: " << videoUrl << endl; }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.