Exemplo n.º 1
0
 def _new_cookie(self):
     self.cookie_count += 1
     self.logger.info('Fetching new cookie... Total: %d' %
                      self.cookie_count)
     wanted = ('ASP.NET_SessionId', 'mail_test_cookie')
     # return {'ASP.NET_SessionId': 'snx3fqmdztwx0a453uys3f55',
     #         'mail_test_cookie': 'IHIBHIAK'}
     cookie = {s: login(self.user, self.passwd).cookies[s] for s in wanted}
     self.logger.info(cookie)
     return cookie
Exemplo n.º 2
0
    def start_requests(self):
        requests = Request('http://electsys.sjtu.edu.cn/edu/student/elect/electwarning.aspx',
            cookies = login('zxdewr', 'sszh2sc'), 
            dont_filter=True, 
            callback=self.parse
        )

        if type(requests) is list:
            for request in requests:
                yield request
        else:
            yield requests
Exemplo n.º 3
0
 def post(self, *args, **kw):
     resp = self.sess.post(*args, **kw)
     while True:
         try:
             self.handle_outdate(resp)
             self.handle_message(resp)
         except SessionOutdated:
             self.sess = login(self.user, self.passwd)
             # FIXME: initpage needed?
             self.initpage = InitPage(self,
                                      self.sess.get(InitPage.url).text)
             resp = self.sess.post(*args, **kw)
         except MessageError as e:
             resp = self.sess.post(*args, **kw)
         else:
             return resp
Exemplo n.º 4
0
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

from jaccount import login
from bs4 import BeautifulSoup as bs
from sdtMain import asp_params
import requests

ELECT_URL = 'http://electsys.sjtu.edu.cn/edu/student/elect/'

if __name__ == '__main__':
    for cnt in range(5):
        sess = login('zxdewr', 'pypy11u')
        print(asp_params(sess.get(ELECT_URL+'electwarning.aspx').text))



Exemplo n.º 5
0
            'LessonTime1$btnChoose': '选定此教师'
            }
    url = LESSON_URL+'viewLessonArrange.aspx?'+urlencode(query)
    return asp_post(sess, url=url, recover_url=url, params=params)


class course(object):
    def __init__(self, **kwargs):
        self.cid = kwargs['cid']
        self.bsid = kwargs['bsid']
        self.xyid = kwargs['xyid']

if __name__ == '__main__':
    test_course = course(**{'cid': 'PS900', 'bsid': '456723', 'xyid': 'ba231'})
    # qiangke(requests.Session(), test_course)
    main_page(login('zxdewr', 'pypy11u'))
    # sess = login('zxdewr', 'p1ptess')
    # init(sess)


# def autition(sess):
#     # Get this site also work ???
#     # http://electsys.sjtu.edu.cn/edu/student/elect/electcheck.aspx?xklc=1
#     # resp = sess.post(xkurl, data = prepare_form('?xklc=1'))
#     # Can I do not assign sess?
#     # sess, form = init(sess, query='?xklc=1')
#     return init(sess, query='?xklc=1')

# def prepare_cookie(sess):
#     ele_cookies_list = ['ASP.NET_SessionId', 'mail_test_cookie']
#     return {s: sess.cookies[s] for s in ele_cookies_list}
Exemplo n.º 6
0
 def __init__(self, username, password):
     self._sess = login(username, password)
     self.cookies = self._get_cookie()
     self.params = self._get_params()
Exemplo n.º 7
0
def main():
    cookie = jaccount.login()
    print(cookie)
Exemplo n.º 8
0
 def __init__(self, user, passwd):
     super().__init__()
     self.user = user
     self.passwd = passwd
     # self.view_param = param
     self.sess = login(self.user, self.passwd)
Exemplo n.º 9
0
 def handle_outdate(self, resp):
     if 'outTimePage.aspx' in resp.url:
         self.sess = login(self.user, self.passwd)
         raise SessionOutdated
Exemplo n.º 10
0
    def update_cookies(self):
        self.cookies = prepare_cookie(login(self.user, self.passwd))

        for c in self.cookies:
            self.driver.add_cookie(c)