标签:
没什么技术含量的一个小软件,用HttpClient登陆某正方系统后读取指定页面然后解析呈现。可以查分数和课表。严重依赖页面的VIEWSTATE,虽然不知道这是啥,理论上应该自动解析出来的,偷懒就成了硬编码。
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
|
protected
void
onPostExecute(String result) { if
(result.equals( "FAIL" ))
{ dialog.dismiss(); new
AlertDialog.Builder(ScoreActivity. this ).setTitle( "错误" ) .setMessage( "无法连接服务器" ).setPositiveButton( "确定" ,
null ) .show(); }
else
if
(result.equals( "" )
|| result == null ||
result.length() == 0 )
{ dialog.dismiss(); new
AlertDialog.Builder(ScoreActivity. this ).setTitle( "错误" ) .setMessage( "网络错误" ).setPositiveButton( "确定" ,
null ) .show(); }
else
if
(result.indexOf( "系统警告" )
!= - 1 )
{ dialog.dismiss(); Toast.makeText(ScoreActivity. this ,
"系统警告,你懂的" , Toast.LENGTH_LONG).show(); }
else
if
(result != null )
{ dialog.dismiss(); Toast.makeText(ScoreActivity. this ,
"查询成功" ,
Toast.LENGTH_SHORT) .show(); Log.d(TAG,
"GetOK" ); Log.d(TAG,
ScoreActivity. this .SCORE_PAGE); Pattern
pattern = Pattern.compile(PATTERN); Matcher
matcher = pattern.matcher(result); while
(matcher.find()) { String
str_year = matcher.group( 1 ); String
str_term = matcher.group( 2 ); String
str_name = matcher.group( 3 ); String
str_type = matcher.group( 4 ); String
str_teacher = matcher.group( 5 ); String
str_test = matcher.group( 6 ); String
str_score = matcher.group( 7 ); String
str_MKEscore = matcher.group( 8 ); if
(str_MKEscore.equals( " " )) str_MKEscore
= "无" ; String
str_rescore = matcher.group( 9 ); if
(str_rescore.equals( " " )) str_rescore
= "无" ; String
str_credit = matcher.group( 11 ); year.add(str_year); term.add(str_term); name.add(str_name); type.add(str_type); teacher.add(str_teacher); test.add(str_test); score.add(str_score); MKEscore.add(str_MKEscore); rescore.add(str_rescore); credit.add(str_credit); } for
( int
i = 0 ;
i < year.size(); ++i) { Map<String,
String> tmp = new
HashMap<String, String>(); tmp.put( "year" ,
year.get(i)); tmp.put( "term" ,
term.get(i)); tmp.put( "name" ,
name.get(i)); tmp.put( "type" ,
type.get(i)); tmp.put( "teacher" ,
teacher.get(i)); tmp.put( "test" ,
test.get(i)); tmp.put( "score" ,
score.get(i)); tmp.put( "MKEscore" ,
MKEscore.get(i)); tmp.put( "rescore" ,
rescore.get(i)); tmp.put( "credit" ,
credit.get(i)); ITEM_INFO.add(tmp); } SimpleAdapter
adapter = new
SimpleAdapter(ScoreActivity. this , ITEM_INFO,
R.layout.score_item_layout, FROM, TO); lv_score.setAdapter(adapter); } } |
标签:
原文地址:http://blog.csdn.net/u014311051/article/details/42675207