Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ptsochantaris/can-proceed

A small, tested, no-frills parser of robots.txt files in Swift.
https://github.com/ptsochantaris/can-proceed

robots-parser robots-txt server-side-swift swift web-clients

Last synced: about 2 months ago
JSON representation

A small, tested, no-frills parser of robots.txt files in Swift.

Awesome Lists containing this project

README

        

Logo

# CanProceed

A small, tested, no-frills parser of `robots.txt` files in Swift.

Currently used in
- [Bloo](https://github.com/ptsochantaris/bloo)

Full docs [can be found here](https://swiftpackageindex.com/ptsochantaris/can-proceed/1.0.0/documentation/canproceed)

## Quick example

```
let exampleRobotsFileLocation = URL(string: "https://www.bbc.co.uk/robots.txt")!
let robotsData = try! Data(contentsOf: exampleRobotsFileLocation)
let robotsText = String(data: robotsData, encoding: .utf8)!

let check = CanProceed.parse(robotsText)

let shouldProceed = check.agent("ChatGPT-User", canProceedTo: "/news"))

guard shouldProceed else {
complain()
return
}

...

check.sitemaps // contains any sitemaps
check.crawlDelay // provides any crawl delay setting
check.sitemps // contains any XML sitemaps
```

## License
Copyright (c) 2024 Paul Tsochantaris. Licensed under the MIT License, see LICENSE for details.