Raised This Month: $51 Target: $400
 12% 

Solved CURL: Downloanding an page ?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 04-27-2022 , 05:40   Re: CURL: Downloanding an page ?
Reply With Quote #4

Quote:
Originally Posted by JocAnis View Post
Where is captcha on gametracker
From cloudflare

Just made this script, I tested it, works as charm, but your only problem is the GameTracker captcha. You can bypass that by changing User-Agent I think.

Also, you'll need cacert.pem inside the amxmodx folder, you can change it's path where you want. You can download a certificate from here: https://curl.se/docs/caextract.html

Tested with a random player from a random server. Results:
Code:
Score: 16552 | Minutes: 15403 | Score p. m.: 1.100000 | Rank: 9
PHP Code:
#include <amxmodx>
#include <curl>

#if !defined MAX_IP_WITH_PORT_LENGTH
#define MAX_IP_WITH_PORT_LENGTH 22
#endif

enum _:PlayerData
{
    
iScore,
    
iMinutes,
    
Float:flAvgScore,
    
iRank
}

new 
g_ePlayerData[MAX_PLAYERS 1][PlayerData]

public 
plugin_init()
{
    
register_concmd("test""SendRequest")
}

public 
SendRequest(id)
{
    new 
CURL:curl curl_easy_init();

    new 
szTemp[100];
    new 
szIP[MAX_IP_WITH_PORT_LENGTH]
    
get_user_ip(0szIPcharsmax(szIP))

    new 
iID[1]
    
iID[0] = id

    
new curl_slist:header

    header 
curl_slist_append(header"text/html; charset=UTF-8");
    
header curl_slist_append(header"User-Agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.126 Mobile Safari/537.36");

    
formatex(szTempcharsmax(szTemp), "https://www.gametracker.com/player/%n/%s/"idszIP);

    if(
curl)
    {
        
curl_easy_setopt(curlCURLOPT_URLszTemp);
        
curl_easy_setopt(curlCURLOPT_COOKIE1);
        
curl_easy_setopt(curlCURLOPT_HTTPHEADERheader)
        
curl_easy_setopt(curlCURLOPT_CUSTOMREQUEST"GET");
        
curl_easy_setopt(curlCURLOPT_FOLLOWLOCATIONtrue);

        
curl_easy_setopt(curlCURLOPT_WRITEFUNCTION"ReceiveData");
        
curl_easy_setopt(curlCURLOPT_WRITEDATAid);
        
curl_easy_setopt(curlCURLOPT_BUFFERSIZE1028);

        
curl_easy_setopt(curlCURLOPT_SSL_VERIFYPEER1);
        
curl_easy_setopt(curlCURLOPT_SSL_VERIFYHOST2);
        
curl_easy_setopt(curlCURLOPT_CAINFO"cstrike/addons/amxmodx/cacert.pem");
        
curl_easy_perform(curl"CurlCallback"iIDsizeof(iID) );
    }
}

public 
ReceiveData(data[], sizenmembid)
{
    
// The position of the "Score: " div
    
new iPos containi(data"Score:")

    if(
iPos != -1)
    {
        
g_ePlayerData[id][iScore] = str_to_num(data[iPos 23])
    }

    
iPos containi(data"Minutes Played:")

    if(
iPos != -1)
    {
        
g_ePlayerData[id][iMinutes] = str_to_num(data[iPos 32])
    }

    
iPos containi(data"Score per Minute:")

    if(
iPos != -1)
    {
        
g_ePlayerData[id][flAvgScore] = str_to_float(data[iPos 34])
    }

    
iPos containi(data"Rank on Server:")

    if(
iPos != -1)
    {
        
g_ePlayerData[id][iRank] = str_to_num(data[iPos 95])
    }

    return 
size nmemb
}

public 
CurlCallback(CURL:cURLHandle CURLcode:codeiID[])
{
    if(
code != CURLE_OK)
    {
        new 
szError[CURL_ERROR_SIZE]
        
curl_easy_strerror(codeszError,charsmax(szError))
        
log_amx("cURL error: %d ^"%s^""codeszError);
    }

    new 
id iID[0]

    
server_print("Score: %d | Minutes: %d | Score p. m.: %f | Rank: %d"g_ePlayerData[id][iScore], g_ePlayerData[id][iMinutes], \
     
g_ePlayerData[id][flAvgScore], g_ePlayerData[id][iRank])

    
curl_easy_cleanup(cURLHandle);

__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]

Last edited by Shadows Adi; 04-27-2022 at 06:18.
Shadows Adi is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:12.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode