1 Star 0 Fork 2

一夜见红 / Danmuku_Python

forked from CaiLibra / Danmuku_Python 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
util.py 756 Bytes
一键复制 编辑 原始数据 按行查看 历史
CaiLibra 提交于 2016-02-28 13:02 . 新建项目
import urllib
import urllib.request
def http_get(url):
response = urllib.request.urlopen(url).read()
response = response.decode('UTF-8')
return response
def get_real_roomid(roomid):
html = http_get("http://live.bilibili.com/" + roomid)
start = html.find("ROOMID = ") + len("ROOMID = ")
end = html.find(";", start)
if 0 < start < end:
real_roomid = html[start:end].replace(' ', '')
return real_roomid
else:
return roomid
def get_str_between(sub, prev, after):
btw = None
prev_loc = sub.find(prev)
if prev_loc >= 0:
prev_loc += len(prev)
after_loc = sub.find(after, prev_loc)
if after_loc > prev_loc:
btw = sub[prev_loc: after_loc]
return btw
Python
1
https://gitee.com/linux0/Danmuku_Python.git
git@gitee.com:linux0/Danmuku_Python.git
linux0
Danmuku_Python
Danmuku_Python
master

搜索帮助