Answer the question
In order to leave comments, you need to log in
How to make a CookieJar in Python?
I have a working code in NodeJs, but I myself write in python:
const request = require('request');
const jar = request.jar();
const cloudscraper = require('cloudscraper').defaults({ jar });
jar.setCookie(request.cookie('session=dhLDWO2muzBCshW3XQ3UzRBPIoFhL734sL47TSnb'), "https://tradeback.io/");
jar.setCookie(request.cookie('remember_web_59ba36addc2b2f9401580f014c7f58ea4e30989d=1142%7CjPt9bbgtNcF6YY5l3CSOIzZPFgov6b5hK2qdZRFxxDmsmfYSOTzKlsZf9JDQ%7C'), "https://tradeback.io/");
cloudscraper({
url: "https://tradeback.io/api/comparison/load?lang=ru",
qs: {
"services":[{"name":"tm_market","updated":60}],"last_item_id":143376,
},
})
.then((data) => {
fs.writeFileSync('writeme.json', data);
});
Answer the question
In order to leave comments, you need to log in
The logic of the script is as follows:
There is a site that you need to go to. The site is protected by cloudflare, which greatly complicates the task: there may be captchas, etc. Node.js has a module for working with cloudflare: cloudscraper, this script uses it. To work with the site, there are two cookies that must be passed along with the request. The module that is used for requests has a Jar -- storage for cookies. Two cookies are passed to this Jar, which are wrapped into objects needed for the module using the request.cookie()
. The generated Jar is specified as the default Jar for requests that cloudscraper will send with .defaults({ jar });
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question