<commit_before>/**
 * Created by 国正 on 2014/7/19.
 */
var request = require('request');
var iconv = require('iconv-lite');
var cheerio = require('cheerio');

var session;

function doRenew(session, bookInfo, callback) {
    if (session == '' || session == null) {
        callback('Not Login');
        return;
    } else if (session.length != 0) {
        if (session[0] == '') {
            callback('Not Login');
            return;
        }
    }
    request
    (
        {
            uri: 'http://192.168.3.11:8080/opac_two/reader/jieshuxinxi.jsp',
            method: 'POST',
            encoding: null,
            headers: {
                ContentType: 'application/x-www-form-urlencoded'
            },
            form: {
                'action': 'Renew',
                'book_barcode': bookInfo.Barcode,
                'department_id': bookInfo.Department,
                'library_id': bookInfo.Library
            }
        }, function (err, res, body) {
            if (err) {
                callback(err);
                return;
            }

            var rawHtml = iconv.decode(body, 'GBK');

            var $ = cheerio.load(rawHtml);
            var temp = $('#my_lib_jieyue').next();
            var alertStr = temp[0].children[0].data.trim();
            alertStr = alertStr.substr(7, alertStr.length - 10);
            if (alertStr.indexOf('续借失败') != -1) {<commit_msg>Fix Do Renew<commit_after>/**
 * Created by 国正 on 2014/7/19.
 */
var request = require('request');
var iconv = require('iconv-lite');
var cheerio = require('cheerio');

var session;

function doRenew(session, bookInfo, callback) {
    if (session == '' || session == null) {
        callback('Not Login');
        return;
    } else if (session.length != 0) {
        if (session[0] == '') {
            callback('Not Login');
            return;
        }
    }
    request
    (
        {
            uri: 'http://222.24.3.7:8080/opac_two/reader/jieshuxinxi.jsp',
            method: 'POST',
            encoding: null,
            headers: {
                ContentType: 'application/x-www-form-urlencoded',
                Cookie: session
            },
            form: {
                'action': 'Renew',
                'book_barcode': bookInfo.Barcode,
                'department_id': bookInfo.Department,
                'library_id': bookInfo.Library
            }
        }, function (err, res, body) {
            if (err) {
                callback(err);
                return;
            }

            var rawHtml = iconv.decode(body, 'GBK');

            var $ = cheerio.load(rawHtml);
            var temp = $('#my_lib_jieyue').next();
            var alertStr = temp[0].children[0].data.trim();
            alertStr = alertStr.substr(7, alertStr.length - 10);
            if (alertStr.indexOf('续借失败') != -1) {
{'fraction_non_alphanumeric': 0.14537755822159493, 'fraction_numerical': 0.019054340155257588, 'mean_word_length': 1.5563570784490532, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4085133', 'n_tokens_mistral': 891, 'n_tokens_neox': 839, 'n_words': 170}