查询4,6级成绩的脚本,批量的哦。

sh/bash/dash/ksh/zsh等Shell脚本
回复
chenwl
帖子: 509
注册时间: 2008-09-06 10:04

查询4,6级成绩的脚本,批量的哦。

#1

帖子 chenwl » 2009-08-20 17:08

代码: 全选

#!/bin/bash

# 查询成绩,参数为准考号
search() {

	ID=$1

	# 查询并将结果写入<准考号>.txt文件中
	curl -e http://cet.99sushe.com \
	-d id=$ID http://cet.99sushe.com/getscore.html \
	-o $1.txt

	# 汇总,将结果加到scores.txt中
	if [ -f $1.txt ]
	then
		cat $1.txt >> scores.txt
		echo "" >> scores.txt
	else
		echo "$1 not found"
	fi
}

# 区间[参数1,参数2]的结果
for id in `seq $1 $2`
do
	search $id
done

exit 0
用法
存为cetscore
chmod +x cetscore
./cetscore 准考号1 准考号2

PS:shell脚本菜菜鸟,非常感谢IRC上v_v,shellex等人的答疑解惑
头像
bones7456
帖子: 8495
注册时间: 2006-04-12 20:05
来自: 杭州
联系:

Re: 查询4,6级成绩的脚本,批量的哦。

#2

帖子 bones7456 » 2009-08-20 17:15

不错,实用,呵呵
关注我的blog: ε==3
头像
isSuS
帖子: 223
注册时间: 2008-11-28 22:22
来自: /广西/钦州

Re: 查询4,6级成绩的脚本,批量的哦。

#3

帖子 isSuS » 2009-08-20 17:19

早上就查完咯,没挂 :em09 ,不过挺不错的说……
头像
O_O_BOT
帖子: 2461
注册时间: 2009-05-20 19:32

Re: 查询4,6级成绩的脚本,批量的哦。

#4

帖子 O_O_BOT » 2009-08-20 17:27

遥远的国度
irc 聊天室
ubuntu-cn 的irc 频道为
irc.ubuntu.com 8001 #ubuntu-cn
UTF8编码 可用 irssi xchat pidgin weechat 登录

http://webchat.freenode.net/?channels=ubuntu-cn
[url]irc://irc.freenode.net/ubuntu-cn[/url]
chenwl
帖子: 509
注册时间: 2008-09-06 10:04

Re: 查询4,6级成绩的脚本,批量的哦。

#5

帖子 chenwl » 2009-08-20 19:01

isSuS 写了:早上就查完咯,没挂 :em09 ,不过挺不错的说……
没过,不过没打算考的说。。。。
头像
tenzu
论坛版主
帖子: 36924
注册时间: 2008-11-21 20:26

Re: 查询4,6级成绩的脚本,批量的哦。

#6

帖子 tenzu » 2009-08-20 19:06

谁借我个考号,谢谢
头像
huangyunjian5407
帖子: 43
注册时间: 2008-05-10 14:12
来自: 广工__龙洞
联系:

Re: 查询4,6级成绩的脚本,批量的哦。

#7

帖子 huangyunjian5407 » 2009-08-20 20:35

忘了准考证号了,还没查到阿 :em20
http://www.gdutsp.com
dell inspiron 1525 (notebook)
cpu:T3200
x3100
From: GDUT, LongDong Campus
chenwl
帖子: 509
注册时间: 2008-09-06 10:04

Re: 查询4,6级成绩的脚本,批量的哦。

#8

帖子 chenwl » 2009-08-20 20:37

tenzu 写了:谁借我个考号,谢谢
310020091214001
头像
wangks18
帖子: 1151
注册时间: 2008-10-27 22:28
来自: 暮色酒馆

Re: 查询4,6级成绩的脚本,批量的哦。

#9

帖子 wangks18 » 2009-08-20 20:37

谢谢 :em11
优猫饼
头像
jarryson
帖子: 4002
注册时间: 2005-08-14 19:53

Re: 查询4,6级成绩的脚本,批量的哦。

#10

帖子 jarryson » 2009-08-20 21:45

这个咋没有结果。。。。
chenwl
帖子: 509
注册时间: 2008-09-06 10:04

Re: 查询4,6级成绩的脚本,批量的哦。

#11

帖子 chenwl » 2009-08-20 22:46

jarryson 写了:这个咋没有结果。。。。
有啊,你号码多少我试试
头像
bobobo80
帖子: 841
注册时间: 2007-12-09 22:36
联系:

Re: 查询4,6级成绩的脚本,批量的哦。

#12

帖子 bobobo80 » 2009-08-20 22:57

又没过,年底继续。
hoogle
帖子: 4
注册时间: 2009-08-10 11:29

Re: 查询4,6级成绩的脚本,批量的哦。

#13

帖子 hoogle » 2009-08-21 17:00

杂不行呢~~
chenwl
帖子: 509
注册时间: 2008-09-06 10:04

Re: 查询4,6级成绩的脚本,批量的哦。

#14

帖子 chenwl » 2009-08-21 19:25

hoogle 写了:杂不行呢~~
输入为2个准考号,第一个小于第二个。
输出在当前目录下的scores.txt文件中。

几点注意:
确保网络连接正常
确保已安装curl
确保准考号区间中存在合法的准考号

下面贴几张我这边的截图。
查询过程
查询过程
查询结果。vim scores.txt
查询结果。vim scores.txt
回复