thu_student 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +45 -0
- data/README.md +44 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/thu_student/version.rb +3 -0
- data/lib/thu_student.rb +73 -0
- data/pkg/thu_student-0.1.0.gem +0 -0
- data/thu_student.gemspec +33 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 18e29d6a3694769095e950384ab03413aecab28f
|
4
|
+
data.tar.gz: 422a943da72a31dc53db966fc1765d64064de30c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 480216b150ba4970a9da662db9994b53488045b240636ab489e912f7220e3c4539614ed8afed551afe0fc10b9939402515e652b95ee42b5c7c43e7fa193d48df
|
7
|
+
data.tar.gz: eb0c096570056b1cb5731d66cb9e3d517b836e1ac22102f72343bf91816128852d8444c94e13b201ac3b4da52332098ce9bcd0e557148f0dc98d6a77528687dc
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
thu_student (0.1.0)
|
5
|
+
mechanize (~> 2.7.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
domain_name (0.5.20160310)
|
11
|
+
unf (>= 0.0.5, < 1.0.0)
|
12
|
+
http-cookie (1.0.2)
|
13
|
+
domain_name (~> 0.5)
|
14
|
+
mechanize (2.7.4)
|
15
|
+
domain_name (~> 0.5, >= 0.5.1)
|
16
|
+
http-cookie (~> 1.0)
|
17
|
+
mime-types (>= 1.17.2, < 3)
|
18
|
+
net-http-digest_auth (~> 1.1, >= 1.1.1)
|
19
|
+
net-http-persistent (~> 2.5, >= 2.5.2)
|
20
|
+
nokogiri (~> 1.6)
|
21
|
+
ntlm-http (~> 0.1, >= 0.1.1)
|
22
|
+
webrobots (>= 0.0.9, < 0.2)
|
23
|
+
mime-types (2.99.1)
|
24
|
+
mini_portile2 (2.0.0)
|
25
|
+
net-http-digest_auth (1.4)
|
26
|
+
net-http-persistent (2.9.4)
|
27
|
+
nokogiri (1.6.7.2)
|
28
|
+
mini_portile2 (~> 2.0.0.rc2)
|
29
|
+
ntlm-http (0.1.1)
|
30
|
+
rake (10.5.0)
|
31
|
+
unf (0.1.4)
|
32
|
+
unf_ext
|
33
|
+
unf_ext (0.0.7.2)
|
34
|
+
webrobots (0.1.2)
|
35
|
+
|
36
|
+
PLATFORMS
|
37
|
+
ruby
|
38
|
+
|
39
|
+
DEPENDENCIES
|
40
|
+
bundler (~> 1.11)
|
41
|
+
rake (~> 10.0)
|
42
|
+
thu_student!
|
43
|
+
|
44
|
+
BUNDLED WITH
|
45
|
+
1.11.2
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# ThuStudent
|
2
|
+
快速獲取東海大學學生個人基本資料
|
3
|
+
需要帳號密碼登入
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
加入這行到您的 Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'thu_student'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install thu_student
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
取得個人基本資料
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
ThuStudent.profile('學號','密碼')
|
27
|
+
```
|
28
|
+
|
29
|
+
取得個人成績總表
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
ThuStudent.transcript('學號','密碼')
|
33
|
+
```
|
34
|
+
|
35
|
+
## Development
|
36
|
+
|
37
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
38
|
+
|
39
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/herber523/thu_student.
|
44
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "thu_student"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/thu_student.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'thu_student/version'
|
2
|
+
|
3
|
+
module ThuStudent
|
4
|
+
def self.profile(username, password)
|
5
|
+
agent = Mechanize.new
|
6
|
+
page = agent.get('http://fsis.thu.edu.tw/mosi/ccsd3/ccsd3_gen.php?job=stud&loginn=Y')
|
7
|
+
form = page.forms.first
|
8
|
+
|
9
|
+
form['username'] = username
|
10
|
+
form['passwd'] = password
|
11
|
+
|
12
|
+
l_page = form.submit.body.split('n="').last.split('";').first
|
13
|
+
agent.get("http://fsiso.thu.edu.tw#{l_page}")
|
14
|
+
|
15
|
+
profiles = agent.get('http://fsiso.thu.edu.tw/wwwstud/STUD_V6/INFO/MyProfile.php?job=personinfo')
|
16
|
+
|
17
|
+
profiles = profiles.search('table tbody tr td')
|
18
|
+
|
19
|
+
student_id = profiles[0].text.split(":").last
|
20
|
+
name = profiles[1].text.split(":").last
|
21
|
+
sex = profiles[2].text.split(":").last
|
22
|
+
birthday = profiles[3].text.split(":").last
|
23
|
+
birth_year = birthday.split(' ')[1].to_i + 1911
|
24
|
+
birth_month = birthday.split(' ')[3]
|
25
|
+
birth_day = birthday.split(' ')[5]
|
26
|
+
birthday = "#{birth_year}/#{birth_month}/#{birth_day}"
|
27
|
+
id = profiles[4].text.split(":").last
|
28
|
+
type = profiles[5].text.split(":").last
|
29
|
+
grade = profiles[6].text.split(":").last
|
30
|
+
identity = profiles[7].text.split(":").last
|
31
|
+
country = profiles[8].text.split(":").last
|
32
|
+
status = profiles[9].text.split(":").last
|
33
|
+
guardian = profiles[10].text.split(":").last
|
34
|
+
home_address = profiles[11].text.split(":").last
|
35
|
+
home_phone = profiles[12].text.split(":").last
|
36
|
+
address = profiles[13].text.split(":").last
|
37
|
+
use_phone = profiles[14].text.split(":").last
|
38
|
+
telephone = profiles[15].text.split(":").last
|
39
|
+
|
40
|
+
hash = []
|
41
|
+
|
42
|
+
hash << { student_id: student_id, name: name, sex: sex, birthday: birthday, id: id, type: type, grade: grade, identity: identity, country: country, status: status, guardian: guardian, home_address: home_address, home_phone: home_phone, address: address, use_phone: use_phone, teltphone: telephone }
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.transcript(username, password)
|
46
|
+
agent = Mechanize.new
|
47
|
+
page = agent.get('http://fsis.thu.edu.tw/mosi/ccsd3/ccsd3_gen.php?job=stud&loginn=Y')
|
48
|
+
form = page.forms.first
|
49
|
+
|
50
|
+
form['username'] = username
|
51
|
+
form['passwd'] = password
|
52
|
+
|
53
|
+
l_page = form.submit.body.split('n="').last.split('";').first
|
54
|
+
agent.get("http://fsiso.thu.edu.tw#{l_page}")
|
55
|
+
|
56
|
+
transcripts = agent.get('http://fsiso.thu.edu.tw/wwwstud/STUD_V6/COURSE/rcrd_all.php')
|
57
|
+
|
58
|
+
transcripts = transcripts.search('#no-more-tables tbody tr')
|
59
|
+
hash = []
|
60
|
+
transcripts.each do |transcript|
|
61
|
+
transcript = transcript.search('td')
|
62
|
+
year = transcript[0].text
|
63
|
+
semester = transcript[1].text
|
64
|
+
course_id = transcript[2].text
|
65
|
+
name = transcript[3].text
|
66
|
+
credit = transcript[4].text
|
67
|
+
score = transcript[5].text
|
68
|
+
hash << { year: year, semester: semester, course_id: course_id, name: name, credit: credit, score: score }
|
69
|
+
end
|
70
|
+
|
71
|
+
hash
|
72
|
+
end
|
73
|
+
end
|
Binary file
|
data/thu_student.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'thu_student/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "thu_student"
|
8
|
+
spec.version = ThuStudent::VERSION
|
9
|
+
spec.authors = ["herber523"]
|
10
|
+
spec.email = ["herber523@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Write a short summary, because Rubygems requires one.}
|
13
|
+
spec.description = %q{Write a longer description or delete this line.}
|
14
|
+
spec.homepage = "https://github.com/herber523/thu_course"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
17
|
+
# delete this section to allow pushing this gem to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
22
|
+
end
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
spec.add_runtime_dependency "mechanize" , "~> 2.7.0"
|
32
|
+
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: thu_student
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- herber523
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mechanize
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.7.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.7.0
|
55
|
+
description: Write a longer description or delete this line.
|
56
|
+
email:
|
57
|
+
- herber523@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- Gemfile
|
63
|
+
- Gemfile.lock
|
64
|
+
- README.md
|
65
|
+
- Rakefile
|
66
|
+
- bin/console
|
67
|
+
- bin/setup
|
68
|
+
- lib/thu_student.rb
|
69
|
+
- lib/thu_student/version.rb
|
70
|
+
- pkg/thu_student-0.1.0.gem
|
71
|
+
- thu_student.gemspec
|
72
|
+
homepage: https://github.com/herber523/thu_course
|
73
|
+
licenses: []
|
74
|
+
metadata:
|
75
|
+
allowed_push_host: https://rubygems.org
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.5.1
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Write a short summary, because Rubygems requires one.
|
96
|
+
test_files: []
|