Пример #1
0
 def __init__(self, train_id, path='学习'):
     login = Login()
     self.session = login.login()
     self.train_id = train_id
     current_path = os.path.abspath(__file__)
     self.path = os.path.abspath(
         os.path.join(current_path, '../../../', path))
Пример #2
0
def login_test():
    session = Login().login()
    # url = 'https://edu.51cto.com/center/wejob/center/trains?page=1&size=1000'
    url = "https://edu.51cto.com/center/course/user/ajax-info-new?page=1&size=5&cate_id=0"
    resp = session.get(url)
    print resp.request.headers
    print resp.text
    url2 = "https://edu.51cto.com/center/course/user/get-study-course"
    session.get(url2).text
    s = ""
Пример #3
0
def course_download(course_id, course_name):
    '''
    下载课程, 比如: https://edu.51cto.com/course/18136.html
    course_id是3223
    course_name是课程的名字, u"MyBatis视频教程[IntelliJ IDEA版本]"
    '''
    session = Login().login()
    lesson.Lesson(session).set_course(
        course_id, course_name).lesson_list().download_m3u8()
Пример #4
0
import WeiJob, Course
from cto import Login
download_type = {
    1: {
        "name": "微职位",
        "fun": WeiJob.run
    },
    2: {
        "name": "课程",
        "fun": Course.run
    },
}

if __name__ == '__main__':
    try:
        ss = Login().login()
        fun = lambda x: x
        while True:
            print "请选择课程类型:"
            for i in download_type:
                print "%d:%s" % (i, download_type[i]['name'])

            print "输入0退出"
            input = raw_input("请选择:")
            # input = "1"

            try:
                input = int(input)
            except ValueError:
                print "无效的输入:", input
            else:
Пример #5
0
 def __init__(self, course_id):
     login = Login()
     self.session = login.login()
     self.course_id = course_id
Пример #6
0
# coding=utf-8
from lxml import etree
from Queue import Queue
import threading
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from bs4 import BeautifulSoup
import json, re, cto
from models import Train, Train_course, Course_lesson
from cto import Login
login = Login()
session = login.login()

q = Queue(1000)
sql_uri = 'mysql://*****:*****@localhost/51cto?charset=utf8mb4'


class Wejob(
        object, ):
    action = ('info', 'download')
    engine = create_engine(sql_uri)
    con = sessionmaker(bind=engine)

    def train(self):
        con = self.con()
        train_id = q.get()
        while train_id:
            result = con.query(Train).filter_by(train_id=train_id).all()
            if result:
                if result[0].status:
                    train_id = q.get()