crawlee
crawlee copied to clipboard
Proxy authentication error
Which package is this bug report for? If unsure which one to select, leave blank
@crawlee/cheerio (CheerioCrawler)
Issue description
I slightly modified the demo of the official website and used ProxyConfiguration to set a proxy list. Error 407 was reported, but my authentication information was carried in the url. I am not sure what operation to do
This is the exception log:
/usr/local/bin/node /Users/admin/Desktop/codebaes/crawlee_uitl/req.js
(node:93791) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
INFO CheerioCrawler: Starting the crawler.
WARN CheerioCrawler: Reclaiming failed request back to the list or queue. Detected a session error, rotating session...
Proxy responded with 407 Proxy Authentication Required: 29 bytes
{"id":"35Zqyzcm4WOh60y","url":"https://www.zhihu.com/question/603336478/answer/3406593764","retryCount":1}
WARN CheerioCrawler: Reclaiming failed request back to the list or queue. Detected a session error, rotating session...
Proxy responded with 407 Proxy Authentication Required: 29 bytes
{"id":"35Zqyzcm4WOh60y","url":"https://www.zhihu.com/question/603336478/answer/3406593764","retryCount":2}
WARN CheerioCrawler: Reclaiming failed request back to the list or queue. Detected a session error, rotating session...
Proxy responded with 407 Proxy Authentication Required: 29 bytes
{"id":"35Zqyzcm4WOh60y","url":"https://www.zhihu.com/question/603336478/answer/3406593764","retryCount":3}
WARN CheerioCrawler: Reclaiming failed request back to the list or queue. Detected a session error, rotating session...
Proxy responded with 407 Proxy Authentication Required: 29 bytes
{"id":"35Zqyzcm4WOh60y","url":"https://www.zhihu.com/question/603336478/answer/3406593764","retryCount":4}
WARN CheerioCrawler: Reclaiming failed request back to the list or queue. Detected a session error, rotating session...
Proxy responded with 407 Proxy Authentication Required: 29 bytes
{"id":"35Zqyzcm4WOh60y","url":"https://www.zhihu.com/question/603336478/answer/3406593764","retryCount":5}
WARN CheerioCrawler: Reclaiming failed request back to the list or queue. Detected a session error, rotating session...
Proxy responded with 407 Proxy Authentication Required: 29 bytes
{"id":"35Zqyzcm4WOh60y","url":"https://www.zhihu.com/question/603336478/answer/3406593764","retryCount":6}
WARN CheerioCrawler: Reclaiming failed request back to the list or queue. Detected a session error, rotating session...
Proxy responded with 407 Proxy Authentication Required: 29 bytes
{"id":"35Zqyzcm4WOh60y","url":"https://www.zhihu.com/question/603336478/answer/3406593764","retryCount":7}
WARN CheerioCrawler: Reclaiming failed request back to the list or queue. Detected a session error, rotating session...
Proxy responded with 407 Proxy Authentication Required: 29 bytes
{"id":"35Zqyzcm4WOh60y","url":"https://www.zhihu.com/question/603336478/answer/3406593764","retryCount":8}
WARN CheerioCrawler: Reclaiming failed request back to the list or queue. Detected a session error, rotating session...
Proxy responded with 407 Proxy Authentication Required: 29 bytes
{"id":"35Zqyzcm4WOh60y","url":"https://www.zhihu.com/question/603336478/answer/3406593764","retryCount":9}
WARN CheerioCrawler: Reclaiming failed request back to the list or queue. Detected a session error, rotating session...
Proxy responded with 407 Proxy Authentication Required: 29 bytes
{"id":"35Zqyzcm4WOh60y","url":"https://www.zhihu.com/question/603336478/answer/3406593764","retryCount":10}
ERROR CheerioCrawler: Request failed and reached maximum retries. Error: Detected a session error, rotating session...
Proxy responded with 407 Proxy Authentication Required: 29 bytes
at CheerioCrawler._requestFunction (/Users/admin/Desktop/codebaes/crawlee_uitl/node_modules/@crawlee/http/internals/http-crawler.js:448:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async wrap (/Users/admin/Desktop/codebaes/crawlee_uitl/node_modules/@apify/timeout/cjs/index.cjs:54:21) {"id":"35Zqyzcm4WOh60y","url":"https://www.zhihu.com/question/603336478/answer/3406593764","method":"GET","uniqueKey":"https://www.zhihu.com/question/603336478/answer/3406593764"}
INFO CheerioCrawler: All requests from the queue have been processed, the crawler will shut down.
INFO CheerioCrawler: Final request statistics: {"requestsFinished":0,"requestsFailed":1,"retryHistogram":[null,null,null,null,null,null,null,null,null,null,1],"requestAvgFailedDurationMillis":77,"requestAvgFinishedDurationMillis":null,"requestsFinishedPerMinute":0,"requestsFailedPerMinute":41,"requestTotalDurationMillis":77,"requestsTotal":1,"crawlerRuntimeMillis":1456}
INFO CheerioCrawler: Error analysis: {"totalErrors":1,"uniqueErrors":1,"mostCommonErrors":["1x: Detected a session error, rotating session... (/Users/admin/Desktop/codebaes/crawlee_uitl/node_modules/@crawlee/http/internals/http-crawler.js:448:23)"]}
INFO CheerioCrawler: Finished! Total 1 requests: 0 succeeded, 1 failed. {"terminal":true}
进程已结束,退出代码为 0
Code sample
async function getReqCheerio(url, push_redis, proxyUrls) {
const start_time = Math.ceil(Date.now() / 1000);
let crawlerOptions = {
...opt,
async requestHandler({ request, response, body, proxyInfo }) {
// console.log('URL:', request.url);
console.log('Used proxy:', proxyInfo);
push_redis({
url: request.url,
html: body.toString(),
status: response.statusCode,
rt: Math.ceil(Date.now() / 1000) - start_time,
});
},
};
if (proxyUrls && proxyUrls.length > 0) {
crawlerOptions.proxyConfiguration = new ProxyConfiguration({
proxyUrls:proxyUrls,
})
}
const crawler = new CheerioCrawler(crawlerOptions);
await crawler.run([url]);
}
const proxyUrls = ["http://**:**@***.225.30.161:11273"];
await getReqCheerio('https://www.zhihu.com/question/603336478/answer/3406593764', console.log, proxyUrls);
Package version
Node.js version
v21.1.0
Operating system
macos
Apify platform
- [ ] Tick me if you encountered this issue on the Apify platform
I have tested this on the next release
No response
Other context
No response
This agent, I only use other programming languages, or other modules is OK, you can disguise my ip, please take a look, thank you😭😭😭😭