Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

191 modify library calendar url #193

Merged
merged 2 commits into from
Aug 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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