Crawl workupload.com by CURL

Hi các bạn,

Có ông anh làm site ThemeCenter nhờ crawl data của workupload.com

Trang này không giống những trang khác, khi có link trực tiếp của file cũng không tải được mà phải có đoạn Cookie, sau 1 hồi mò mẫm loay hoay thì mềnh đã kéo được data của workupload về

$url = "https://workupload.com/file/HhUs4hP3E7G";
// get the token from workupload servers
$curl = curl_init();
curl_setopt_array($curl, [
   CURLOPT_URL => $url,
   CURLOPT_RETURNTRANSFER => true,
   CURLOPT_COOKIEJAR => 'cookie.txt',
]);

$result = curl_exec($curl);
$token = substr(strstr($result, "token"), 6, 64);

// get the download URL from workupload servers
$curl = curl_init();
curl_setopt_array($curl, [
    CURLOPT_URL => "https://workupload.com/api/file/getDownloadServer/" . basename($url),
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_COOKIEFILE => 'cookie.txt',
]);
$result = curl_exec($curl);
$json = json_decode($result, true);
$dl_url = $json['data']['url'];

// download the file
$curl = curl_init();
curl_setopt_array($curl, [
    CURLOPT_URL => $dl_url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_COOKIEFILE => 'cookie.txt',
    CURLOPT_TIMEOUT => 99999,
]);
$file_contents = curl_exec($curl);

// save the file to disk
$filename = 'download/' . basename($dl_url) . '.rar';
file_put_contents($filename , $file_contents);

Mình còn làm thêm đoạn code giải nén file rar, đổi tên, xóa bớt 1 số file sau đó zip lại rồi upload lên Google Drive nữa 🙂

Chúc các bạn download được nhiều tài liệu 🙂

1 Comment

  • Attn. Director,

    We are interested in your products. Please contact us if your company can handle a bulk supply of your products to Cameroon.
    Please send your reply to [email protected]

    HRM Bah Mbi

    HRM Bah Mbi
    Posted October 24, 2023

Leave a comment