광주시교육청통합도서관 추가
This commit is contained in:
@@ -10,11 +10,198 @@ using System.IO;
|
||||
|
||||
namespace BokBonCheck
|
||||
{
|
||||
public class NamguLibrarySearcher_Munhwa : NamguLibrarySearcher
|
||||
{
|
||||
public NamguLibrarySearcher_Munhwa()
|
||||
{
|
||||
SiteName = "남구통합도서관(문화정보도서관)"; // 문화관 검색기
|
||||
}
|
||||
|
||||
protected override void SelectLibrary(WebDriverWait wait)
|
||||
{
|
||||
IWebElement searchBox = null;
|
||||
try
|
||||
{
|
||||
var selector = "#clickAll";
|
||||
searchBox = wait.Until(d => d.FindElement(By.CssSelector(selector)));
|
||||
if (searchBox != null && searchBox.Selected==true)
|
||||
{
|
||||
searchBox.Click(); // 전체체크박스가 체크되어 있으면 클릭해서 해제
|
||||
}
|
||||
else return;
|
||||
|
||||
selector = "#libMA";
|
||||
searchBox = wait.Until(d => d.FindElement(By.CssSelector(selector)));
|
||||
if (searchBox != null && searchBox.Selected==false)
|
||||
{
|
||||
searchBox.Click(); // 문화관 체크박스 선택
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
public class NamguLibrarySearcher_Purungil : NamguLibrarySearcher
|
||||
{
|
||||
public NamguLibrarySearcher_Purungil()
|
||||
{
|
||||
SiteName = "남구통합도서관(푸른길도서관)";
|
||||
}
|
||||
|
||||
protected override void SelectLibrary(WebDriverWait wait)
|
||||
{
|
||||
IWebElement searchBox = null;
|
||||
try
|
||||
{
|
||||
var selector = "#clickAll";
|
||||
searchBox = wait.Until(d => d.FindElement(By.CssSelector(selector)));
|
||||
if (searchBox != null && searchBox.Selected == true)
|
||||
{
|
||||
searchBox.Click(); // 전체체크박스가 체크되어 있으면 클릭해서 해제
|
||||
}
|
||||
else return;
|
||||
|
||||
selector = "#libMB";
|
||||
searchBox = wait.Until(d => d.FindElement(By.CssSelector(selector)));
|
||||
if (searchBox != null && searchBox.Selected == false)
|
||||
{
|
||||
searchBox.Click(); // 체크박스 선택
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class NamguLibrarySearcher_Children : NamguLibrarySearcher
|
||||
{
|
||||
public NamguLibrarySearcher_Children()
|
||||
{
|
||||
SiteName = "남구통합도서관(청소년도서관)";
|
||||
}
|
||||
|
||||
protected override void SelectLibrary(WebDriverWait wait)
|
||||
{
|
||||
IWebElement searchBox = null;
|
||||
try
|
||||
{
|
||||
var selector = "#clickAll";
|
||||
searchBox = wait.Until(d => d.FindElement(By.CssSelector(selector)));
|
||||
if (searchBox != null && searchBox.Selected == true)
|
||||
{
|
||||
searchBox.Click(); // 전체체크박스가 체크되어 있으면 클릭해서 해제
|
||||
}
|
||||
else return;
|
||||
|
||||
selector = "#libMC";
|
||||
searchBox = wait.Until(d => d.FindElement(By.CssSelector(selector)));
|
||||
if (searchBox != null && searchBox.Selected == false)
|
||||
{
|
||||
searchBox.Click(); // 체크박스 선택
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class NamguLibrarySearcher_Hyocheon : NamguLibrarySearcher
|
||||
{
|
||||
public NamguLibrarySearcher_Hyocheon()
|
||||
{
|
||||
SiteName = "남구통합도서관(효천어울림도서관)";
|
||||
}
|
||||
|
||||
protected override void SelectLibrary(WebDriverWait wait)
|
||||
{
|
||||
IWebElement searchBox = null;
|
||||
try
|
||||
{
|
||||
var selector = "#clickAll";
|
||||
searchBox = wait.Until(d => d.FindElement(By.CssSelector(selector)));
|
||||
if (searchBox != null && searchBox.Selected == true)
|
||||
{
|
||||
searchBox.Click(); // 전체체크박스가 체크되어 있으면 클릭해서 해제
|
||||
}
|
||||
else return;
|
||||
|
||||
selector = "#libSW";
|
||||
searchBox = wait.Until(d => d.FindElement(By.CssSelector(selector)));
|
||||
if (searchBox != null && searchBox.Selected == false)
|
||||
{
|
||||
searchBox.Click(); // 체크박스 선택
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
public class NamguLibrarySearcher_Smart : NamguLibrarySearcher
|
||||
{
|
||||
public NamguLibrarySearcher_Smart()
|
||||
{
|
||||
SiteName = "남구통합도서관(스마트도서관)";
|
||||
}
|
||||
|
||||
protected override void SelectLibrary(WebDriverWait wait)
|
||||
{
|
||||
IWebElement searchBox = null;
|
||||
try
|
||||
{
|
||||
var selector = "#clickAll";
|
||||
searchBox = wait.Until(d => d.FindElement(By.CssSelector(selector)));
|
||||
if (searchBox != null && searchBox.Selected == true)
|
||||
{
|
||||
searchBox.Click(); // 전체체크박스가 체크되어 있으면 클릭해서 해제
|
||||
}
|
||||
else return;
|
||||
|
||||
selector = "#libSQ";
|
||||
searchBox = wait.Until(d => d.FindElement(By.CssSelector(selector)));
|
||||
if (searchBox != null && searchBox.Selected == false)
|
||||
{
|
||||
searchBox.Click(); // 체크박스 선택
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class NamguLibrarySearcher : ILibrarySearcher
|
||||
{
|
||||
public string SiteName => "남구통합도서관";
|
||||
public string SiteName { get; protected set; } = "남구통합도서관(전체)";
|
||||
public string SiteUrl => "https://lib.namgu.gwangju.kr/main/bookSearch";
|
||||
|
||||
virtual protected void SelectLibrary(WebDriverWait wait)
|
||||
{
|
||||
IWebElement searchBox = null;
|
||||
try
|
||||
{
|
||||
var selector = "#clickAll";
|
||||
searchBox = wait.Until(d => d.FindElement(By.CssSelector(selector)));
|
||||
if (searchBox != null && searchBox.Selected == false)
|
||||
{
|
||||
searchBox.Click(); // 전체체크박스가 해제되어 있으면 클릭해서 선택
|
||||
}
|
||||
else return;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<BookSearchResult> SearchAsync(string searchTerm)
|
||||
{
|
||||
var result = new BookSearchResult
|
||||
@@ -54,15 +241,18 @@ namespace BokBonCheck
|
||||
|
||||
// 명시적으로 서비스와 옵션을 사용하여 드라이버 생성
|
||||
driver = new ChromeDriver(service, options);
|
||||
|
||||
|
||||
// 자동화 감지 방지
|
||||
((IJavaScriptExecutor)driver).ExecuteScript("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})");
|
||||
|
||||
|
||||
driver.Navigate().GoToUrl(SiteUrl);
|
||||
|
||||
// 페이지 로딩 대기
|
||||
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(15));
|
||||
|
||||
//대상도서관 선택
|
||||
SelectLibrary(wait);
|
||||
|
||||
// 검색창 찾기 (남구통합도서관 사이트의 특정 선택자 사용)
|
||||
IWebElement searchBox = null;
|
||||
try
|
||||
@@ -193,11 +383,4 @@ namespace BokBonCheck
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface ILibrarySearcher
|
||||
{
|
||||
string SiteName { get; }
|
||||
string SiteUrl { get; }
|
||||
Task<BookSearchResult> SearchAsync(string searchTerm);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user