获取个人借阅信息---图书馆客户端
来源:互联网 发布:行政事业单位记账软件 编辑:程序博客网 时间:2024/05/01 21:57
在上一篇利用jsoup解析个人信息----图书馆客户端,获得个人基本信息后,便有了进一步的需求:获取当前借阅的详细信息
获取的方法还是一样的,利用jsoup解析借阅信息页面,获得所需数据,封装成LendBookInfo,然后将其加入一个List中。
借阅信息详情页如下:
模拟get请求得到其html字符串,代码较简单
/** *获取当前借阅信息。 必须在login()调用之后 * * @return */public static String getCurLendInfo() {String curLendInfo = null;/** * * location----------- /patroninfo~S3*chx/1****82/top * * 目标-------------/patroninfo~S3*chx/1****82/items * * tem_location----/patroninfo~S3*chx/1****82 * * */HttpGet httpget = null;String tem_location = location.substring(0, location.lastIndexOf("/"));System.out.println("tem_location---->" + tem_location);try {httpget = new HttpGet(baseUrl + tem_location + "/items");response = httpclient.execute(httpget);// 发送get请求int code = response.getStatusLine().getStatusCode();System.out.println(response.getStatusLine());if (code == 200) {if (response != null) {curLendInfo = EntityUtils.toString(response.getEntity(),HTTP.UTF_8);}}} catch (ClientProtocolException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}return curLendInfo;}
得到html后,便可以利用jsoup进行解析。打开firedebug,进行分析。代码如下:
/** * 获取借阅的数目信息 * * @param lendInfoHtml * 借阅信息详情html * @return 借阅信息列表 */public static List<LendBookInfo> getLendBookInfos(String lendInfoHtml) {List<LendBookInfo> lendBookInfos = new ArrayList<>();Document document = Jsoup.parse(lendInfoHtml);Element table = document.getElementsByClass("patFunc").get(0);// 表格Elements items = table.getElementsByClass("patFuncEntry");// 数目信息集合for (Element item : items) {LendBookInfo bookInfo = null;Element ele_title = item.getElementsByClass("patFuncTitle").get(0);// 题名String bookDetail = ele_title.child(0).text();Element ele_barCode = item.getElementsByClass("patFuncBarcode").get(0);// 条形码String barCode = ele_barCode.text();Element ele_status = item.getElementsByClass("patFuncStatus").get(0);// 状态String status = ele_status.text();Element ele_callNumber = item.getElementsByClass("patFuncCallNo").get(0);// 索书号String callNumber = ele_callNumber.text();bookInfo = new LendBookInfo(bookDetail, callNumber, status, barCode);lendBookInfos.add(bookInfo);}return lendBookInfos;}
测试如下:
public static void main(String[] args) {boolean isConn = LibraryUtil.login(stuNo, password);/** * 若登陆成功则将信息保存到数据库(学号、密码需要加密)。 */if (isConn) {String resultHtml = LibraryUtil.getResultHtml();UserInfo userInfo = UserInfoHandler.getUserInfo(resultHtml);userInfo.setStuNo(stuNo);userInfo.setPassword(password);System.out.println("========");System.out.println(userInfo.toString());String lendInfoHtml = LibraryUtil.getCurLendInfo();List<LendBookInfo> lendBookInfos = UserInfoHandler.getLendBookInfos(lendInfoHtml);for (LendBookInfo bookInfo : lendBookInfos) {System.out.println(bookInfo);}}}
测试结果:
待续……
1 0
- 获取个人借阅信息---图书馆客户端
- Python爬虫实战---抓取图书馆借阅信息
- 图书馆书本借阅系统
- 图书馆借阅管理系统
- 图书馆借阅的书单记录
- 一个图书馆的借阅书刊的案例
- 2013.10-2015.9 图书馆借阅书籍情况
- 基于jdbc的图书馆借阅系统
- php:获取校内图书借阅信息,并用飞信进行提醒
- 获取客户端信息
- 获取客户端信息
- jsp获取客户端信息
- jsp获取客户端信息
- jsp获取客户端信息
- 获取客户端浏览器信息
- .net获取客户端信息
- 客户端获取电脑硬件信息
- php 获取客户端信息
- sphinx做增量索引更新合并
- LeetCode(90) Decode Ways
- 多人协作书籍协作的准备工作
- Codeforces Round #235 (Div. 2) D. Roman and Numbers(状压dp)
- 一致性哈希算法介绍,及java实现
- 获取个人借阅信息---图书馆客户端
- dell 服务器查看raid 信息
- Cocos2d-x 3.2 大富翁游戏项目开发-第七部分 获取角色路径_1
- 【C++ Primer】【学习笔记】【第三章】标准库类型之:vector类型
- 【C++ Primer】【练习题】【3.13】【3.17】求vector<int>相邻元素的和
- SQL中内连接和外连接
- DNS中的正向解析与反向解析
- UIImageView的contentMode属性
- 零基础HTML5游戏制作教程 第1章