コード例 #1
0
ファイル: bili.py プロジェクト: dhcmrlchtdj/vcrawler
def bilibili(url):
    """分析页面,调用相应函数下载视频"""
    url, down = Compiled.bili_url(url)
    html = get_src(url)
    if down == 'all':
        # 判断是单个视频还是视频列表
        length = Compiled.bili_list_len(html)
        if length:
            bili_all(url, length)
    bili_one(url, html)
コード例 #2
0
ファイル: bili.py プロジェクト: biddyweb/vcrawler
def bilibili(url):
    """分析页面,调用相应函数下载视频"""
    url, down = Compiled.bili_url(url)
    html = get_src(url)
    if down == 'all':
        # 判断是单个视频还是视频列表
        length = Compiled.bili_list_len(html)
        if length:
            bili_all(url, length)
    bili_one(url, html)
コード例 #3
0
ファイル: bili.py プロジェクト: dhcmrlchtdj/vcrawler
def bili_one(url, html=None):
    if not html:
        html = get_src(url)

    # 获取视频来源
    v_site, v_id = Compiled.bili_source(html)
    # 下载
    if v_site == 'cid':
        download_by_cid(v_id)
    else:
        raise NotImplementedError(v_site + '=' + v_id)
コード例 #4
0
ファイル: bili.py プロジェクト: biddyweb/vcrawler
def bili_one(url, html=None):
    if not html:
        html = get_src(url)

    # 获取视频来源
    v_site, v_id = Compiled.bili_source(html)
    # 下载
    if v_site == 'cid':
        download_by_cid(v_id)
    else:
        raise NotImplementedError(v_site + '=' +  v_id)
コード例 #5
0
ファイル: evict.py プロジェクト: Tiensbakung/masterthesis
def aggregate(fn):
    capacity = defaultdict(int)
    evict = 0
    for line in open(fn):
        if line.startswith('[PKT] <0'):
            src, dst, t, i, s, q = disect_packet(line)
            if q == 0:
                if capacity[src] < 1000:
                    capacity[src] += 1
                else:
                    evict += 1
        elif line.startswith('[CLN]'):
            src = get_src(line)
            capacity[src] -= 1
            evict += 1
    return evict
コード例 #6
0
ファイル: evict.py プロジェクト: Tiensbakung/masterthesis
def aggregate(fn):
    capacity = defaultdict(int)
    evict = 0
    for line in open(fn):
        if line.startswith('[PKT] <0'):
            src, dst, t, i, s, q = disect_packet(line)
            if q == 0:
                if capacity[src] < 1000:
                    capacity[src] += 1
                else:
                    evict += 1
        elif line.startswith('[CLN]'):
            src = get_src(line)
            capacity[src] -= 1
            evict += 1
    return evict
コード例 #7
0
def process_request(conn, addr):
    req = conn.recv(1024)
    # 防止浏览器发送空请求导致崩溃
    if len(req.split()) < 2:
        return
    src = get_src(req)

    if src in MOVE301.keys():
        conn.sendall(move301(src))
    elif src in MOVE302.keys():
        conn.sendall(move302(src))
    else:
        request = Request(req)
        print(request.method + ' > ' + str(request.src))
        response = request.response

        if request.src in ROUTES:
            response = ROUTES[request.src](request)

        conn.sendall(response)

    conn.close()
コード例 #8
0
def parse_tree_fragment(model, fragment):
    '''
    Parse a single source fragment present in the tree.

    All source fragments are eventually decomposed into 
    a set of transitions and places.
    '''

    if len(fragment.src) > 0:
        #if source code is present parse

        head = []
        tail = []

        status = parse_segment(model, head, tail, fragment.src)

        #replace fragment connections
        #swap source fragment with processed fragment including all
        #parent-children connections

        model.elements.remove(fragment)
        for p in model.elements:
            #remove any children connections pointing to the processed fragment
            if fragment in p.children:
                p.children.remove(fragment)
                if len(head) > 0:
                    p.children += head
        for e in tail:
            #inherit all children connections in processed fragment
            e.children += fragment.children

    elif fragment.label != '':
        #if source code is missing load the corresponding fragment source first

        fragment.src = util.get_src(fragment.label, model)
        fragment.label = ''
    else:
        raise Exception("Undefined fragment in the elements array")
コード例 #9
0
ファイル: bili.py プロジェクト: dhcmrlchtdj/vcrawler
def download_by_cid(video_id):
    xml_url = 'http://interface.bilibili.tv/playurl?cid=' + video_id
    xml = get_src(xml_url)
    video_links = Compiled.bili_video_links(xml)
    Download.gets(video_links)
コード例 #10
0
ファイル: bili.py プロジェクト: biddyweb/vcrawler
def download_by_cid(video_id):
    xml_url = 'http://interface.bilibili.tv/playurl?cid=' + video_id
    xml = get_src(xml_url)
    video_links = Compiled.bili_video_links(xml)
    Download.gets(video_links)