提问人:Silence 提问时间:11/15/2023 最后编辑:Silence 更新时间:11/15/2023 访问量:42
带有 Flaresolver 的 C++ cURL 库结果为 403
C++ cURL Lib with Flaresolver result is 403
问:
你好, 我目前正在使用 C++ 进行网络抓取项目。对于这个项目,我使用 Flaresolver 作为代理来绕过 Cloudflare 的反机器人措施。尽管阅读了多篇文章和资源,我发现自己陷入困境,无法继续。
任何人都可以提供一些指导或向我指出相关资源,以帮助我了解如何在 C++ 环境中有效地使用 Flaresolver 进行网络抓取?
提前感谢您的帮助。
我的代码在这里:
curl = curl_easy_init();
if (curl) {
// Set the URL you want to request
curl_easy_setopt(curl, CURLOPT_URL, "https://www.namemc.com/search?q=Discs");
//Set a custom user agent
curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36");
// Set the proxy server and port
curl_easy_setopt(curl, CURLOPT_PROXY, "http://127.0.0.1");
curl_easy_setopt(curl, CURLOPT_PROXYPORT, 8191);
// Replace with your proxy port
// Set a timeout in seconds (e.g., 10 seconds)
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 65);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
// Perform the request
res = curl_easy_perform(curl);
long http_code = 0;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code);
std::cout << "HTTP Response Code: " << http_code << std::endl;
// Check for errors
if (res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
// Clean up
curl_easy_cleanup(curl);
}
我似乎无法解决这个问题。 我相信在运行时值得一提的是,我希望 flaresolver 输出它已收到连接,但无论出于何种原因,它都没有显示在 CLI 中。
我的应用程序输出:
* Trying 127.0.0.1:8191...
* Connected to 127.0.0.1 (127.0.0.1) port 8191
* CONNECT tunnel: HTTP/1.1 negotiated
* allocate connect buffer
* Establish HTTP proxy tunnel to www.namemc.com:443
> CONNECT www.namemc.com:443 HTTP/1.1
Host: www.namemc.com:443
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
Proxy-Connection: Keep-Alive
< HTTP/1.1 404 Not Found
< Content-Length: 49
< Content-Type: application/json
< Date: Tue, 14 Nov 2023 16:35:28 GMT
< Server: waitress
<
* CONNECT tunnel failed, response 404
* Closing connection
HTTP Response Code: 0
curl_easy_perform() failed: Failure when receiving data from the peer
Flare 求解器输出
2023-11-14 16:31:42 INFO FlareSolverr 3.3.6
2023-11-14 16:31:42 INFO Testing web browser installation...
2023-11-14 16:31:42 INFO Platform: Windows-10-10.0.19045-SP0
2023-11-14 16:31:42 INFO Chrome / Chromium path: D:\flaresolverr\chrome\chrome.exe
2023-11-14 16:31:42 INFO Chrome / Chromium major version: 115
2023-11-14 16:31:42 INFO Launching web browser...
2023-11-14 16:31:47 INFO FlareSolverr User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
2023-11-14 16:31:47 INFO Test successful!
2023-11-14 16:31:47 INFO Serving on http://0.0.0.0:8191
答: 暂无答案
评论
curl_easy_setopt
Discs"()
"curl_easy_perform() failed: Failure when receiving data from the peer"