再次动手:Mac下下载B站弹幕的东西

      No Comments on 再次动手:Mac下下载B站弹幕的东西

请移步http://www.cnbeining.com/?p=330   。
 
重复造轮子了,whatever。
 

import os
def main(vid, p):
    cid = 0
    print('Fetching webpage...')
    os.system('rm -r temp.html')
    os.system('curl -o temp.html --compressed http://www.bilibili.tv/video/av'+vid+'/index_'+p+'.html')
    print('Reading...')
    f = open('temp.html', 'r')
    alllines = f.readlines();
    f.close()
    for lines in alllines:
        #print(lines)
        if 'cid=' in lines:
            cid = lines.split('&')
            cid = cid[0].split('=')
            cid = cid[-1]
            print('cid is ' + cid)
            break
    if cid is 0:
        print('Cannot find cid!')
        exit()
    print('Fetching XML...')
    os.system('curl -o '+cid+'.xml --compressed  http://comment.bilibili.tv/'+cid+'.xml')
    #os.system('gzip -d '+cid+'.xml.gz')
    print('The XML file, ' + cid + '.xml should be ready...enjoy!')
    os.system('rm -r temp.html')
    exit()
vid = str(input('av'))
p = str(input('P'))
main(vid, p)

Do whatever heck you like with it.

Leave a Reply

Your email address will not be published.