Skip to content

Commit

Permalink
add scraper functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMoonThatRises committed Aug 10, 2023
1 parent 9c336e3 commit 9346479
Show file tree
Hide file tree
Showing 27 changed files with 804 additions and 328 deletions.
33 changes: 22 additions & 11 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
{
"pins" : [
{
"identity" : "swxmlhash",
"kind" : "remoteSourceControl",
"location" : "https://github.com/drmohundro/SWXMLHash",
"state" : {
"revision" : "4d0f62f561458cbe1f732171e625f03195151b60",
"version" : "7.0.1"
"object": {
"pins": [
{
"package": "SwiftSoup",
"repositoryURL": "https://github.com/scinfu/SwiftSoup.git",
"state": {
"branch": null,
"revision": "8b6cf29eead8841a1fa7822481cb3af4ddaadba6",
"version": "2.6.1"
}
},
{
"package": "SWXMLHash",
"repositoryURL": "https://github.com/drmohundro/SWXMLHash",
"state": {
"branch": null,
"revision": "4d0f62f561458cbe1f732171e625f03195151b60",
"version": "7.0.1"
}
}
}
],
"version" : 2
]
},
"version": 1
}
6 changes: 4 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ let package = Package(
targets: ["StudentVue"])
],
dependencies: [
.package(url: "https://github.com/drmohundro/SWXMLHash", from: "7.0.1")
.package(url: "https://github.com/drmohundro/SWXMLHash", from: "7.0.1"),
.package(url: "https://github.com/scinfu/SwiftSoup.git", from: "2.6.0")
],
targets: [
.target(
name: "StudentVue",
dependencies: [
"SWXMLHash"
"SWXMLHash",
"SwiftSoup"
])
],
swiftLanguageVersions: [.v5]
Expand Down
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Swift library for interacting with StudentVue's api. This project was heavily in
## Installation

```swift
.package(url: "https://github.com/TheMoonThatRises/StudentVue.swift", from: "0.0.1")
.package(url: "https://github.com/TheMoonThatRises/StudentVue.swift", from: "0.1.0")
```

## Basic usage
Expand All @@ -23,21 +23,26 @@ import StudentVue
let client = StudentVue(domain: "something.edupoint.com", username: "123456789", password: "password")
```

With the client initialized, you can access information by using the provided functions such as `getGradeBook`, `getClassSchedule`, `getSchoolInfo`, and many more. If one of the functions fails to parse or you want to access information in which a data structure is not created, you can call the `makeServiceRequest` and parse the XML manually.
With the client initialized, you can access information from the official api by using the provided functions such as `getGradeBook`, `getClassSchedule`, `getSchoolInfo`, and many more. If one of the functions fails to parse or you want to access information in which a data structure is not created, you can call the `makeServiceRequest` and parse the XML manually.

```swift
let gradebook = client.getGradeBook()
let gradebook = try await client.api.getGradeBook()
```

### Static functions

For some functions, logging in is not required, such as getting district zip codes

```swift
let districts = try await client.api.getDistricts(zip: "a zip code")
```

import StudentVue
You can also use the scraper which gives more information and functionality, but is not fully implemented. With the following example you can assess whether or not a username and password combination are valid. The line below that will you out of StudentVue. More and easier functionality will be added to the scraper in the future.

```swift
try await client.scraper.login() // Log into StudentVue

let districts = StudentVue.getDistricts(zip: "a zip code")
try await client.scraper.logout() // Log out of StudentVue
```

## Todo List
Expand Down
20 changes: 20 additions & 0 deletions Sources/StudentVue/Extensions/String+PercentEncoding.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// String+PercentEncoding.swift
//
//
// Created by TheMoonThatRises on 3/9/23.
//

import Foundation

extension String {
/// Percent encode if possible
///
/// - Parameters:
/// - withAllowedCharacters: Set of characters to encode
///
/// - Returns: String percent encoded with character set
func percentEncoding(withAllowedCharacters: CharacterSet) -> String {
self.addingPercentEncoding(withAllowedCharacters: withAllowedCharacters) ?? self
}
}
21 changes: 21 additions & 0 deletions Sources/StudentVue/Extensions/String+replacing.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// String+replacing.swift
//
//
// Created by TheMoonThatRises on 8/9/23.
//

import Foundation

extension String {
/// Replace substring with another substring in the current string
///
/// - Parameters:
/// - from: Substring of characters to replace
/// - with: Substring of replacing characters
///
/// - Returns: String with substring replaced
public func replacing(_ from: String, with: String) -> Self {
self.replacingOccurrences(of: from, with: with)
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ struct SoapXML {
var password: String
var skipLoginLog: Bool
var parent: Bool
var webServiceHandleName: StudentVue.WebServices
var methodName: StudentVue.Methods
var webServiceHandleName: StudentVueApi.WebServices
var methodName: StudentVueApi.Methods
var paramStr: [String: [String: String]]

private var formattedParamStr: String {
Expand Down
Loading

0 comments on commit 9346479

Please sign in to comment.