This repository has been archived by the owner on Feb 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ArchivedCode.swift
75 lines (71 loc) · 1.96 KB
/
ArchivedCode.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//
// ArchivedCode.swift
// OurCampus
//
// Created by Rafael Goldstein on 1/15/19.
// Copyright © 2019 Rafael Goldstein. All rights reserved.
//
import Foundation
func parseHTMLDeps(html: String) -> Void {
var depsList = [String]()
do {
let doc = try Kanna.HTML(html: html, encoding: String.Encoding.utf8)
// Search for nodes by CSS selector
for p in doc.css("div[class^='item']") {
depsList.append(p.text!)
}
}
catch {
print("error")
}
var depsFinal = [String]()
for i in depsList {
if i.contains("\n") {
// do nothing
}
else {
if i.contains("Department") {
let p = i.replacingOccurrences(of: " Department", with: "")
depsFinal.append(p)
}
else if i.contains("Program") {
let p = i.replacingOccurrences(of: " Program", with: "")
depsFinal.append(p)
}
else {
depsFinal.append(i)
}
}
}
self.depData = depsFinal
self.typePickerView.reloadAllComponents()
}
func parseHTMLProfs(html: String) -> Void {
var profsList = [String]()
do {
let doc = try Kanna.HTML(html: html, encoding: String.Encoding.utf8)
// Search for nodes by CSS selector
for p in doc.css("h3[class^='altheader']") {
profsList.append(p.text!)
}
}
catch {
print("error")
}
var finalProfs = [[String]]()
for i in profsList {
let lines = i.components(separatedBy: CharacterSet.newlines)
var names = [String]()
for x in lines {
if x == "" {
// do nothing
}
else {
let n = x.trimmingCharacters(in: .whitespacesAndNewlines)
names.append(n)
}
}
finalProfs.append(names)
}
self.professors = finalProfs
}