Esempio n. 1
0
def write_all_my_lesssion():

    path = u'lession'
    if not os.path.exists(path):
        os.mkdir(path)

    cookies = load_cookies(flag=2)

    result = parse_my_lession_json()
    for item in result:
        school = item['school']
        name = item['name']
        number = item['ids']

        print school, name, number

        filename = u'%s-%s.json' % (school, name)
        status = write_lession_json(number=number,
                                    name=filename,
                                    path=path,
                                    cookies=cookies)
        if status:
            pass
        else:
            print u'sleep 3 second!'
            time.sleep(3)
Esempio n. 2
0
def test():
    if not os.path.exists('vpn.html'):
        cookies = load_cookies(flag=0)
        html = homepage(cookies=cookies)
        write_html(html=html)
    else:
        html = read_html()

    print parse_html(html=html)
Esempio n. 3
0
def add_lession(tid=1002977006):

    url='http://www.icourse163.org/dwr/call/plaincall/CourseBean.startTermLearn.dwr'

    cookies=load_cookies(flag=1)
    csrfKey=cookies['NTESSTUDYSI']

    cookies=parse_cookies(cookies=cookies)

    data={
        'callCount':1,
        'scriptSessionId':'${scriptSessionId}190',
        'httpSessionId':csrfKey,
        'c0-scriptName':'CourseBean',
        'c0-methodName':'startTermLearn',
        'c0-id':0,
        'c0-param0':'string:%s'%tid,
        'c0-param1':'null:null',
        'batchId':1531726020251,
        }

    r=My_requests(url=url,method='post',data=data)
    r.headers['Cookie']=cookies

    content=r.get_content()

    reg=re.compile('\((.*?)\)')

    result=reg.findall(content)

    print result

    if result:
        '''
        "'1531726020251','0',1374827585"
        result 为以上形式表示添加课程成功

        '''
        result=result[0]
        l=result.split(',')

        for i in l:
            try:
                int(i.replace("'",''))

            except:
                print u'add lession failed!可能原因:该课程已关闭'
                print result
                return False
        print u'add lession successfully!'
        return True

    else:
        print u'add lession failed,可能原因:该课程已关闭'
        print result
        return False
Esempio n. 4
0
def get_user_info(user='******', cookies=None):
    cookies = load_cookies(flag=0)
    url = 'https://weibo.com/%s' % user

    response = requests.get(url=url,
                            headers=headers,
                            cookies=cookies,
                            timeout=30)
    encoding = response.encoding
    print encoding
    content = response.content.decode(encoding)

    print content
Esempio n. 5
0
def get_user_follower(userid=1006065936137028, cookies=None):

    cookies = load_cookies(flag=0)
    url = 'https://weibo.com/p/%s/follow' % userid

    response = requests.get(url=url,
                            headers=headers,
                            cookies=cookies,
                            timeout=30)
    encoding = response.encoding
    print encoding
    content = response.content.decode(encoding)

    print content
Esempio n. 6
0
def main(user=234498509):

    cookies = load_cookies(flag=0)
    d = get_id_and_domain(user=user, cookies=cookies)
    page_id = d['page_id']
    domain = d['domain']
    for page in range(1, 2):

        return run(domain=domain,
                   page_id=page_id,
                   pagebar=0,
                   page=page,
                   cookies=cookies)
        run(domain=domain,
            page_id=page_id,
            pagebar=1,
            page=page,
            cookies=cookies)
        time.sleep(2)
Esempio n. 7
0
def get_my_lession(p=1,flag=1):
    '''p参数表示页码,flag取值0,1,2!1表示本地载入,2表示网络载入,3表示用户选择本地载入还是网络'''

    url='http://www.icourse163.org/web/j/learnerCourseRpcBean.getMyLearnedCoursePanelList.rpc'

    data=dict(
            type=30,
            p=p,
            psize=32,
            courseType=1,
            )

    headers={'User-Agent':'Mozilla/5.0 (Windows; U; Windows NT 5.2) Gecko/2008070208 Firefox/3.0.1'}
    cookies=load_cookies(flag=flag)
    params={'csrfKey':cookies['NTESSTUDYSI']}
    headers['Cookie']=parse_cookies(cookies)
    res=requests.post(url=url,headers=headers,params=params,data=data,timeout=30)

    j=res.json()

    return j
Esempio n. 8
0
def main():
    # init_log()
    t = time.asctime()
    cookies = load_cookies(flag=1)
    if isinstance(cookies, dict):
        log = u'get cookies dict,will checkin'
        write_log(log=log)
        try:
            msg = checkin(cookies=cookies)
            html = homepage(cookies=cookies)
            status = parse_html(html=html)
        except:
            log = traceback.format_exc()
            print log
            write_log(log=log)
    else:
        log = u'type of cookies is not dict'
        write_log(log=log)
        msg = u'can not get userful cookies,checkin failed'

    message = dict(logintime=time.asctime(), msg=msg, status=status)
    message = json.dumps(message, ensure_ascii=False)
    # print message
    mail(msg=message, title=u'vpn签到')
Esempio n. 9
0
# _*_ coding:utf-8 _*_

from cookies import load_cookies
from config import headers
import requests
import re, json, time

cookies = load_cookies(flag=0)

t = time.time() * 1000
url = 'https://weibo.com/aj/f/unfollow?ajwvr=6&__rnd=%d' % (t)
print url
data = dict(uid="2089278455", refer_flag='unfollow_all', _t=0)
print data
headers[
    'Referer'] = 'https://weibo.com/p/1005052096868947/myfollow?t=%d&cfs=&Pl_Official_RelationMyfollow__95_page=1' % (
        t)
res = requests.post(url=url,
                    cookies=cookies,
                    headers=headers,
                    timeout=30,
                    data=data)
content = res.json()
print json.dumps(content, ensure_ascii=False, indent=4)