[PY]BiliBili-Live直播间录制工具

详情请到Friends下的rabbit的博客查看解析。
由他的影响我也做了一个QWQ,直接上代码辣

import md5,requests,threading,time
_clock_ = 0
times = 0
def _clock():
    global _clock_
    while 1:
        _clock_ = _clock_ + 1
        time.sleep(1)
        print _clock_
        if(_clock_ == times):
            break
def _txt(start_str, end, html):
    start = html.find(start_str)
    if start >= 0:
        start += len(start_str)
        end = html.find(end, start)
        if end >= 0:
            return html[start:end].strip()
def liveURL(url):
    web = requests.get(url)
    ROOMID = 'cid=' + _txt('var ROOMID =',';',web.content)
    appkey = 'appkey=85eb6835b0a1034e'
    ts = 'ts='+str(time.time())
    players = 'player=1'
    quality = 'quality=0'
    m = md5.new()
    m.update(appkey+'&'+ROOMID+'&'+players+'&'+quality+'&'+ts)
    sign = m.hexdigest()
    web = requests.get('http://live.bilibili.com/api/playurl?'+appkey+'&'+ROOMID+'&'+players+'&'+quality+'&'+ts+'&'+sign)
    live_url = _txt('<url><![CDATA[',']]></url>',web.content)
    print live_url
    downLoad(live_url)
def downLoad(url):
    global _clock_,time
    down = requests.get(url)
    with open('D:\\'+str(time.time())+'.flv','wb') as code:
        for data in down.iter_content(chunk_size=4096):
            code.write(data)
            if _clock_ == time:
                break

if __name__ == '__main__':
    url = raw_input("Please Input Bilibili-Live's url:")
    times = int(raw_input("Please Input luzhishijian(i don't know this word for english.QVQ):"))
    t = threading.Thread(target=_clock())
    liveURL(url)
    t.start()
Tags: python, bilibili

易语言内部执行python语句&易语言编写python包

网络上查了查资料。执行python语句十分简单,就是调用Pythonx.x.dll内部的三个函数,C++调用方式也一样
直接给出E引用:

.DLL命令 Py_Initialize, 整数型, "python34", "@Py_Initialize"

.DLL命令 Py_Finalize, 整数型, "python34", "@Py_Finalize"

.DLL命令 PyRun_SimpleStringFlags, 整数型, "python34",
"@PyRun_SimpleStringFlags"

.参数 command, 文本型
.参数 flags, 整数型

运行方式就是在任意代码内放置:

Py_Initialize ()
PyRun_SimpleStringFlags (PYTHON语句, 0)
Py_Finalize ()

即可。
接下来是E编写python包。
和CPP差不多

因为代码太长,并且网上也有现成的,就直接丢上来了_(:3」∠)_。。。
主要就是自定义一个类型包含包信息让python识别就行了,之后调用PYthonX.X.DLL建立包
说到底还不是都是DLL变形而来的
同时还要注意PY的Object类型是整数。E_pythonbag.rar

Tags: python, 易语言

python-多线程单IP扫描器和IP段扫描器

闲的蛋疼话几十分钟写的,IP段扫描器那个生成IP段是网上抄来的,实在叼。我花了好久才弄懂。
代码很短也很简单,我就直接帖上来了


阅读全文...

Tags: python