Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

StackOverflow Point

StackOverflow Point Navigation

  • Web Stories
  • Badges
  • Tags
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Web Stories
  • Badges
  • Tags
Home/ Questions/Q 185456
Alex Hales
  • 0
Alex HalesTeacher
Asked: June 9, 20222022-06-09T22:56:41+00:00 2022-06-09T22:56:41+00:00

Download via CURL from the FREEPIK site in PHP using cookies and CSRF

  • 0

[ad_1]

I have a robot
And through CURL, I can get the download link from the Freepik site
But there is a problem
After receiving 3 or 4 download links
The CSRF value changes and the robot stops
Can I get the CSRF parameter via a cookie or some other method?
Or suggest another way to do this
I also changed the user agent, but the problem was not resolved

      $csrf = c06cdeb93e405ee73b8da754b3c7d4a1;
      $useragent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.63 Safari/537.36";
      $cookie="cookies/freepik.txt";
      $url = "https://www.freepik.com/xhr/download-url/$id";
      $ch = curl_init($url);
      curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
      curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
      curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept:application/json, text/plain, */*', "User-Agent:$useragent", 'x-requested-with:XMLHttpRequest', "x-csrf-token:$csrf"));
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      $result = curl_exec($ch);
      curl_close($ch);
      $res = json_decode($result);
      if($res->success) {
        # $name = $res->filename;
        $download = $res->url;
        $file = downloadFile($download);

[ad_2]

  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report
Leave an answer

Leave an answer
Cancel reply

Browse

Sidebar

Ask A Question

Related Questions

  • xcode - Can you build dynamic libraries for iOS and ...

    • 0 Answers
  • bash - How to check if a process id (PID) ...

    • 396 Answers
  • database - Oracle: Changing VARCHAR2 column to CLOB

    • 370 Answers
  • What's the difference between HEAD, working tree and index, in ...

    • 361 Answers
  • Amazon EC2 Free tier - how many instances can I ...

    • 0 Answers

Stats

  • Questions : 43k

Subscribe

Login

Forgot Password?

Footer

Follow

© 2022 Stackoverflow Point. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.