Я пытаюсь загрузить веб -страницу с конкретного веб -сайта (Bandcamp). Я получаю разные результаты, хотя запрос кажется одинаковым:
- В Windows 10, используя httpclient в C#: Я получаю «JavaScript отключен в вашем браузере». Windows 10, используя Curl: я получаю ожидаемый контент веб -страницы. Таким образом, я не понимаю, почему я не получаю такой же ответ от сервера в зависимости от программы /ОС.
Код: Выделить всё
curl -D curl-response-headers.txt -o curl-response-content.html -v https://weneverlearnedtolive.bandcamp.com/album/silently-i-threw-them-skyward 2> curl-request.log < /code> Вот результаты: < /p> curl-request.log: % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 * Host weneverlearnedtolive.bandcamp.com:443 was resolved. * IPv6: (none) * IPv4: 151.101.1.91, 151.101.193.91, 151.101.65.91, 151.101.129.91 * Trying 151.101.1.91:443... * schannel: disabled automatic use of client certificate * ALPN: curl offers http/1.1 * ALPN: server accepted http/1.1 * Connected to weneverlearnedtolive.bandcamp.com (151.101.1.91) port 443 * using HTTP/1.x > GET /album/silently-i-threw-them-skyward HTTP/1.1 > Host: weneverlearnedtolive.bandcamp.com > User-Agent: curl/8.13.0 > Accept: */* > * Request completely sent off < HTTP/1.1 200 OK < Connection: keep-alive < Content-Length: 304708 < server: nginx < cache-control: no-cache, no-store < content-type: text/html; charset=UTF-8 < link: ; rel="canonical" < via: 1.1 varnish, 1.1 varnish < referrer-policy: no-referrer-when-downgrade < set-cookie: BACKENDID3=c2flexocentral-h0d1-5; path=/; Secure < accept-ranges: bytes < content-security-policy: base-uri 'none'; object-src 'none'; report-uri https://bandcamp.com/api/cspreport/1/violation; script-src http: https: 'nonce-s3hx8+at705S3MtOqJD9rA==' 'report-sample' 'strict-dynamic' < Date: Sat, 04 Oct 2025 20:52:07 GMT < X-Served-By: cache-par-lfpg1960032-PAR, cache-par-lfpg1960095-PAR < X-Cache: MISS, MISS < X-Cache-Hits: 0, 0 < X-Timer: S1759611127.329393,VS0,VE632 < Vary: Accept-Encoding, Accept-Encoding < Strict-Transport-Security: max-age=63072000 < { [1371 bytes data] 10 297k 10 32059 0 0 44258 0 0:00:06 --:--:-- 0:00:06 44341 100 297k 100 297k 0 0 311k 0 --:--:-- --:--:-- --:--:-- 311k * Connection #0 to host weneverlearnedtolive.bandcamp.com left intact - curl-response-content.html содержит то, что я ожидаю: Содержание веб-страницы:
Код: Выделить всё
Silently, I Threw Them Skyward | We Never Learned To Live [...] [...]
Теперь, когда я хочу загружать одну и ту же веб -страницу, используя httpclient в c#, я не получаю содержание веб -страницы, но вместо этого веб -сайт whovascript in diavscript in diseer in diseer in diavescript in in diemprows in diavescript. Рассмотрим следующий код C#, используя net48 (результаты одинаковы с Net80 ):
Код: Выделить всё
using System.IO;
using System.Net.Http;
var httpClient = new HttpClient();
// Mimicing the curl headers
httpClient.DefaultRequestHeaders.Add("Host", "weneverlearnedtolive.bandcamp.com");
httpClient.DefaultRequestHeaders.Add("User-Agent", "curl/8.13.0");
httpClient.DefaultRequestHeaders.Add("Accept", "*/*");
var htmlCode = await httpClient.GetStringAsync("https://weneverlearnedtolive.bandcamp.com/album/silently-i-threw-them-skyward");
File.WriteAllText(@"C:\temp\httpclient-response.html", htmlCode);
< /code>
Вот результаты: < /p>
[list]
[*] httpclient-response.html < /em> в Windows 10: < /p>
Client Challenge
#loading-error {
font-size: 16px;
font-family: 'Inter', sans-serif;
margin-top: 10px;
margin-left: 10px;
display: none;
}
[img]/_fs-ch-1T1wmsGaOgGaSxcX/assets/errorIcon.svg[/img]
alt=""
role="presentation"
class="error-icon"
/>
JavaScript is disabled in your browser.
Please enable JavaScript to proceed.
A required part of this site couldn’t load. This may be due to a browser
extension, network issues, or browser settings. Please check your
connection, disable any ad blockers, or try using a different browser.
function loadScript(src) {
return new Promise((resolve, reject) => {
const script = document.createElement('script');
script.onload = resolve;
script.onerror = (event) => {
console.error('Script load error event:', event);
document.getElementById('loading-error').style.display = 'block';
loadingError.setAttribute('aria-hidden', 'false');
reject(
new Error(
`Failed to load script: ${src}, Please contact the service administrator.`
)
);
};
script.src = src;
document.body.appendChild(script);
});
}
loadScript('/_fs-ch-1T1wmsGaOgGaSxcX/errors.js')
.then(() => {
const script = document.createElement('script');
script.src = '/_fs-ch-1T1wmsGaOgGaSxcX/script.js?reload=true';
script.onerror = (event) => {
console.error('Script load error event:', event);
const errorMsg = new Error(
`Failed to load script: ${script.src}. Please contact the service administrator.`
);
console.error(errorMsg);
handleScriptError();
};
document.body.appendChild(script);
})
.catch((error) => {
console.error(error);
});
Полный журнал, слишком долго, чтобы опубликовать здесь: https://pastebin.com/0ekbmpuv
Извлечение:
Код: Выделить всё
System.Net.Http Verbose: 0 : [7800] Entering HttpClientHandler#45004109::.ctor()
System.Net.Http Verbose: 0 : [7800] Exiting HttpClientHandler#45004109::.ctor()
System.Net Information: 0 : [7800] Current OS installation type is 'Client'.
System.Net.Http Verbose: 0 : [7800] Entering HttpClient#2383799::.ctor(HttpClientHandler#45004109)
System.Net.Http Information: 0 : [7800] Associating HttpClient#2383799 with HttpClientHandler#45004109
System.Net.Http Verbose: 0 : [7800] Exiting HttpClient#2383799::.ctor()
System.Net.Http Verbose: 0 : [7800] Entering HttpClient#2383799::.ctor(HttpClientHandler#45004109)
System.Net.Http Verbose: 0 : [7800] Exiting HttpClient#2383799::.ctor()
System.Net.Http Verbose: 0 : [7800] Entering HttpRequestMessage#21454193::.ctor(Method: GET, Uri: 'https://weneverlearnedtolive.bandcamp.com/album/silently-i-threw-them-skyward')
System.Net.Http Verbose: 0 : [7800] Exiting HttpRequestMessage#21454193::.ctor()
System.Net.Http Verbose: 0 : [7800] Entering HttpClient#2383799::SendAsync(HttpRequestMessage#21454193: Method: GET, RequestUri: 'https://weneverlearnedtolive.bandcamp.com/album/silently-i-threw-them-skyward', Version: 1.1, Content: , Headers:
{
Host: weneverlearnedtolive.bandcamp.com
User-Agent: curl/8.13.0
Accept: */*
})
System.Net.Http Verbose: 0 : [7800] Entering HttpClientHandler#45004109::SendAsync(HttpRequestMessage#21454193)
[...]
System.Net Information: 0 : [7720] HttpWebRequest#58870012 - Request: GET /album/silently-i-threw-them-skyward HTTP/1.1
System.Net Information: 0 : [7720] ConnectStream#17653682 - Sending headers
{
User-Agent: curl/8.13.0
Accept: */*
Host: weneverlearnedtolive.bandcamp.com
Connection: Keep-Alive
}.
[...]
System.Net.Http Information: 0 : [7720] HttpClient#2383799 - Request for HttpRequestMessage#21454193 completed successfully. Returning response HttpResponseMessage#41488021: StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Connection: keep-alive
link: ; rel="canonical"
referrer-policy: no-referrer-when-downgrade
content-security-policy: base-uri 'none'; object-src 'none'; report-uri https://bandcamp.com/api/cspreport/1/violation; script-src http: https: 'nonce-4SNicugooCStEQCJ71zXaQ==' 'report-sample' 'strict-dynamic'
X-Served-By: cache-par-lfpg1960097-PAR, cache-par-lfpg1960046-PAR
X-Cache: MISS, MISS
X-Cache-Hits: 0, 0
X-Timer: S1759615346.832943,VS0,VE403
Vary: Accept-Encoding
Vary: Accept-Encoding
Strict-Transport-Security: max-age=63072000
Accept-Ranges: bytes
Cache-Control: no-store, no-cache
Date: Sat, 04 Oct 2025 22:02:26 GMT
Set-Cookie: BACKENDID3=flexocentral-wqtw-4; path=/; Secure
Server: nginx
Via: 1.1 varnish
Via: 1.1 varnish
Content-Length: 304704
Content-Type: text/html; charset=UTF-8
}
с использованием c# httpclient , в Windows 11
с той же программой, построенной в Windows 10, но работал на Windows 11, я получаю ожидаемое содержимое веб -страницы. /> [*] httpclient-response.html < /em> в Windows 11: < /p>
Код: Выделить всё
Silently, I Threw Them Skyward | We Never Learned To Live
[...]
[...]
Полный журнал, слишком долго, чтобы публиковать здесь: https://pastebin.com/sichjsrz> extract:
Код: Выделить всё
System.Net.Http Verbose: 0 : [21888] Entering HttpClientHandler#45004109::.ctor()
System.Net.Http Verbose: 0 : [21888] Exiting HttpClientHandler#45004109::.ctor()
System.Net Information: 0 : [21888] Current OS installation type is 'Client'.
System.Net.Http Verbose: 0 : [21888] Entering HttpClient#2383799::.ctor(HttpClientHandler#45004109)
System.Net.Http Information: 0 : [21888] Associating HttpClient#2383799 with HttpClientHandler#45004109
System.Net.Http Verbose: 0 : [21888] Exiting HttpClient#2383799::.ctor()
System.Net.Http Verbose: 0 : [21888] Entering HttpClient#2383799::.ctor(HttpClientHandler#45004109)
System.Net.Http Verbose: 0 : [21888] Exiting HttpClient#2383799::.ctor()
System.Net.Http Verbose: 0 : [21888] Entering HttpRequestMessage#21454193::.ctor(Method: GET, Uri: 'https://weneverlearnedtolive.bandcamp.com/album/silently-i-threw-them-skyward')
System.Net.Http Verbose: 0 : [21888] Exiting HttpRequestMessage#21454193::.ctor()
System.Net.Http Verbose: 0 : [21888] Entering HttpClient#2383799::SendAsync(HttpRequestMessage#21454193: Method: GET, RequestUri: 'https://weneverlearnedtolive.bandcamp.com/album/silently-i-threw-them-skyward', Version: 1.1, Content: , Headers:
{
Host: weneverlearnedtolive.bandcamp.com
User-Agent: curl/8.13.0
Accept: */*
})
System.Net.Http Verbose: 0 : [21888] Entering HttpClientHandler#45004109::SendAsync(HttpRequestMessage#21454193)
[...]
System.Net Information: 0 : [20256] HttpWebRequest#58870012 - Request: GET /album/silently-i-threw-them-skyward HTTP/1.1
System.Net Information: 0 : [20256] ConnectStream#11429296 - Sending headers
{
User-Agent: curl/8.13.0
Accept: */*
Host: weneverlearnedtolive.bandcamp.com
Connection: Keep-Alive
}.
[...]
System.Net.Http Information: 0 : [4128] HttpClient#2383799 - Request for HttpRequestMessage#21454193 completed successfully. Returning response HttpResponseMessage#23264094: StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Connection: keep-alive
X-Served-By: cache-par-lfpg1960078-PAR, cache-par-lfpg1960098-PAR
X-Cache: MISS
X-Cache-Hits: 0
X-Timer: S1759613754.880187,VS0,VE16
Strict-Transport-Security: max-age=63072000
transfer-encoding: chunked
Accept-Ranges: bytes
Cache-Control: no-store, private
Date: Sat, 04 Oct 2025 21:35:53 GMT
Set-Cookie: _fs_ch_st_FSBmUei20MqUiJb9=AVIj7A7j2xFzZyiA6fSINoRRHZoXZ7qHAUlwGmE46LFeJCBixSX5CHJMrGIm8hu65hsZSfU8SoXi3p2you36fsZzgfzG0ZJdwJu8YIwe_vX5qQ89btc5ODfHlaoyAb4oIWPtu8_khLIO_SlUbNwjnxN4AmiWWDKLeH7L418co2tEcKOWpVYQDb6t7JgntY0NurpWPo6IitDzoBCM7arYoFAE_rvExvTSinP77GKGOtUGZCkAhutKOUprWNyYC8g91a7_JJPLiFcF03RqN14wfP1tSlojV7CJbBKyVIV_zz88Mo2F4-G9hbI-ngZOTgEPcP9fW9VPnTqoAiIvAQ==; Max-Age=10; HttpOnly; Path=/
Via: 1.1 varnish
Content-Type: text/html; charset=utf-8
}
< /code>
< /li>
< /ul>
мой вывод < /h1>
http rogred arged является одинаковой (http 1.1), я устанавливаю одни и те же заголовки, что и Curl, и я не вижу рамки .NET, добавляя другие заголовки, когда я анализирую пастинку, используя a proxie, похожий на Fiddly, или даже с анализом. Wireshark:
Таким образом, я не понимаю, что может различить запросы, чтобы сервер отправил свой ответ. В конце я хотел бы получить ожидаемый содержимое веб-страницы в Windows 10 с HttpClient < /code>. < /P>
Несколько нот < /h1>
Это поведение новое с 2025-09-24, я правильно скачал веб-страницу, поэтому я думаю, что они должны были что-то изменить. Http 2 Когда я пытаюсь заставить HTTP 2 с curl , я получаю следующую ошибку, поэтому он подтверждает Curl не лжет, когда он регистрирует HTTP 1.1 :
curl --http2 https://weneverlearnedtolive.bandcamp.c ... em-skyward
curl: option --http2: the installed libcurl version does not support this
< /code>
< /li>
< /ul>
Извините за длинный пост, я надеюсь, что кто -то сможет просветить меня.
Подробнее здесь: https://stackoverflow.com/questions/797 ... st-between