diff --git a/unimarc/unimarc/SearchModel/GwangjuDongguLibSearcher.cs b/unimarc/unimarc/SearchModel/GwangjuDongguLibSearcher.cs index 5435124..96064fe 100644 --- a/unimarc/unimarc/SearchModel/GwangjuDongguLibSearcher.cs +++ b/unimarc/unimarc/SearchModel/GwangjuDongguLibSearcher.cs @@ -22,16 +22,7 @@ namespace BokBonCheck { DefaultRequestHeaders = { - { "User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" }, - { "Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7" }, - { "Accept-Language", "ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7" }, - { "Accept-Encoding", "gzip, deflate, br, zstd" }, - { "Sec-Fetch-Dest", "document" }, - { "Sec-Fetch-Mode", "navigate" }, - { "Sec-Fetch-Site", "none" }, - { "Sec-Fetch-User", "?1" }, - { "Cache-Control", "max-age=0" }, - { "Upgrade-Insecure-Requests", "1" } + { "User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" } } }; @@ -87,9 +78,18 @@ namespace BokBonCheck Console.WriteLine($"광주동구 검색 URL: {searchUrl}"); - // HTTP GET 요청 실행 - var response = await _httpClient.GetAsync(searchUrl); - + // HTTP GET 요청 실행 (추가 헤더 포함) + using (var request = new HttpRequestMessage(HttpMethod.Get, searchUrl)) + { + // 브라우저와 유사한 헤더 추가 + request.Headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"); + request.Headers.Add("Accept-Language", "ko-KR,ko;q=0.8,en-US;q=0.5,en;q=0.3"); + request.Headers.Add("Accept-Encoding", "gzip, deflate, br"); + request.Headers.Add("Connection", "keep-alive"); + request.Headers.Add("Upgrade-Insecure-Requests", "1"); + + var response = await _httpClient.SendAsync(request); + if (!response.IsSuccessStatusCode) { var errorContent = await response.Content.ReadAsStringAsync(); @@ -100,7 +100,7 @@ namespace BokBonCheck // 검색 결과 수 추출 var resultCount = ExtractBookCount(htmlContent, out string errorMessage); - + if (resultCount == -1) { result.BookCount = 0; @@ -114,7 +114,6 @@ namespace BokBonCheck result.ErrorMessage = $"검색성공({resultCount}권)"; } } - } catch (Exception ex) {