25 lines
923 B
Swift
25 lines
923 B
Swift
import ArgumentParser
|
|
import PuttyKit
|
|
|
|
@main
|
|
struct CLI: AsyncParsableCommand {
|
|
static let configuration: CommandConfiguration = .init(
|
|
commandName: "putty",
|
|
abstract: "A utility for getting comic data from GoComics.com.",
|
|
subcommands: [Scrape.self],
|
|
)
|
|
}
|
|
|
|
struct Scrape: AsyncParsableCommand {
|
|
static let configuration = CommandConfiguration(abstract: "Scrape all necessary data.")
|
|
|
|
mutating func run() async throws {
|
|
let fetcher = PageFetcher(webDriverURL: "http://browser:4444")
|
|
let content = try await fetcher.fetchHTML(from: "https://www.gocomics.com/comics/a-to-z",
|
|
waitFor: AToZParser.baseSelector)
|
|
let parsed = try AToZParser.parse(content: content)
|
|
print("Fetch complete: \(parsed.count) features fetched.")
|
|
print("\(parsed.count(where: \.isUpdated)) features updated today.")
|
|
}
|
|
}
|