<commit_before># -*- coding: utf-8 -*-
# @Date    : 2017/2/1
# @Author  : hrwhisper
import codecs
import json
import os
import time
from sys import exit
import requests
from MyOCR import image_to_string


class UserNameOrPasswordError(Exception):
    pass


class LoginUCAS(object):
    def __init__(self, use_onestop=True, vercode_save_name='certCode.jpg'):
        self.username, self.password = LoginUCAS._read_username_and_password()
        self.cnt = 0
        self.__BEAUTIFULSOUPPARSE = 'html5lib'  # or use 'lxml'
        self.session = requests.session()
        self.vercode_save_name = vercode_save_name
        self.use_onestop = use_onestop
        self._init_login_url()

    def _init_login_url(self):
        if self.use_onestop:
            self._onestop_init()
        else:
            self._sep_init()

    def _onestop_init(self):
        self.url = {
            'base_url': 'http://onestop.ucas.ac.cn/home/index',
            'verification_code': None,
            'login_url': 'http://onestop.ucas.ac.cn/Ajax/Login/0'
        }
        # self.session.get(self.url['base_url'])
        self.headers = {
            'Host': 'onestop.ucas.ac.cn',
            'Referer': 'http://onestop.ucas.ac.cn/home/index',
            'X-Requested-With': 'XMLHttpRequest',
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0'
        }
        self.post_data = {
            "username": self.username,
            "password": <PASSWORD>,
            "remember": 'checked',
        }

    def _sep_init(self):
        self.url = {
            'base_url': 'http://sep.ucas.ac.cn/',<commit_msg>update loginUCAS.py<commit_after># -*- coding: utf-8 -*-
# @Date    : 2017/2/1
# @Author  : hrwhisper
import codecs
import json
import os
import time
from sys import exit
import requests
from MyOCR import image_to_string


class UserNameOrPasswordError(Exception):
    pass


class LoginUCAS(object):
    def __init__(self, use_onestop=True, vercode_save_name='certCode.jpg'):
        self.username, self.password = LoginUCAS._read_username_and_password()
        self.cnt = 0
        self.__BEAUTIFULSOUPPARSE = 'html5lib'  # or use 'lxml'
        self.session = requests.session()
        self.vercode_save_name = vercode_save_name
        self.use_onestop = use_onestop
        self._init_login_url()

    def _init_login_url(self):
        if self.use_onestop:
            self._onestop_init()
        else:
            self._sep_init()

    def _onestop_init(self):
        self.url = {
            'base_url': 'http://onestop.ucas.ac.cn/home/index',
            'verification_code': None,
            'login_url': 'http://onestop.ucas.ac.cn/Ajax/Login/0'
        }
        # self.session.get(self.url['base_url'])
        self.headers = {
            'Host': 'onestop.ucas.ac.cn',
            "Connection": "keep-alive",
            'Referer': 'http://onestop.ucas.ac.cn/home/index',
            'X-Requested-With': 'XMLHttpRequest',
            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36",
        }
        self.post_data = {
            "username": self.username,
            "password": self.password,
            "remember": 'checked',
        }

    def _sep_init(self):
        self.url = {
            'base_url': 'http://sep.ucas.ac.cn/',
{'fraction_non_alphanumeric': 0.1326440177252585, 'fraction_numerical': 0.020088626292466764, 'mean_word_length': 2.2125237191650853, 'pattern_counts': {'":': 8, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, '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': '3891588', 'n_tokens_mistral': 1202, 'n_tokens_neox': 1149, 'n_words': 197}