Answer the question
In order to leave comments, you need to log in
How to correctly generate a cookieJar file in js so that later it can be fed to CURL?
you need to make access to the personal account of one service, they don’t have an apish and there is protection from bots
. As a result, you have to pervert. I
log in and get a session using Puppeteer.
And you already need to pull the data using curl, using the data of the received
session .
let cookieJar = await cookies.map(row => {
let cookieRow = []
cookieRow.push(row['domain']) // the domain name
cookieRow.push('FALSE') // include subdomains
cookieRow.push(row['path']) // path
cookieRow.push(row['secure']) // send/receive over HTTPS only
cookieRow.push(row['expires']) //
cookieRow.push(row['name']) // name of the cookie
cookieRow.push(row['value']) // value of the cookie
return cookieRow.join('\t');
}).join('\n')
127.0.0.1 FALSE / false -1 PHPSESSID fd435as2kcpkc3ovah88022e1j
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_USERAGENT, $this->userAgent);
// curl_setopt($ch, CURLOPT_COOKIE, 'PHPSESSID=fd435as2kcpkc3ovah88022e1j;'); // это работает
curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookieJarFile); // при попытке прочитать из файла - не работает
Answer the question
In order to leave comments, you need to log in
1. replace CURLOPT_COOKIEFILE with CURLOPT_COOKIEJAR and see how cookies are saved
2. why the heck do you need to form this format? generate CURLOPT_COOKIE from any format
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question