Skip to content

Commit

Permalink
Merge pull request #193 from tokudai0000/191-modify-library-calendar-url
Browse files Browse the repository at this point in the history
191 modify library calendar url
  • Loading branch information
akidon0000 committed Aug 12, 2024
2 parents 69f7110 + d7d3b90 commit cfaad07
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions Features/LibraryCalendarWebScraper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ public protocol LibraryCalendarWebScraperInterface {
public struct LibraryCalendarWebScraper: LibraryCalendarWebScraperInterface {
public init() {}

private let baseURLString = "https://www.lib.tokushima-u.ac.jp/"

public func getLibraryCalendarURL(libraryUrl: URL) -> RxSwift.Single<URLRequest> {
return .create { observer in
let task = URLSession.shared.dataTask(with: libraryUrl) { (data, response , error) in
Expand All @@ -30,12 +28,12 @@ public struct LibraryCalendarWebScraper: LibraryCalendarWebScraperInterface {
return observer(.failure(WebScrapeError.noDataAvailable(statusCode: statusCode)))
}

var urlStr = self.baseURLString
var urlStr = ""
do {
let doc = try HTML(html: data, encoding: String.Encoding.utf8)
for node in doc.xpath("//a") {
if let str = node["href"], str.contains("pub/pdf/calender/") {
urlStr = urlStr + str
if let str = node["href"], str.contains("drupal/ja/library_calendar/annual/") {
urlStr = str
}
}
} catch let parseError {
Expand Down

0 comments on commit cfaad07

Please sign in to comment.