最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

B站動(dòng)態(tài)轉(zhuǎn)發(fā)抽獎(jiǎng)教程

2019-11-06 21:02 作者:Love丶伊卡洛斯  | 我要投稿

重要提醒!?。?/strong>

? 經(jīng)過大數(shù)據(jù)量測試后發(fā)現(xiàn),程序不能爬取多轉(zhuǎn)發(fā)人數(shù)的所有數(shù)據(jù)。原因是程序內(nèi)API的數(shù)據(jù)不全,并沒有提供所有的轉(zhuǎn)發(fā)人員數(shù)據(jù),導(dǎo)致數(shù)據(jù)的缺失。

? 測試數(shù)據(jù)量 轉(zhuǎn)發(fā)人數(shù)6w+,而https://api.live.bilibili.com/dynamic_repost/v1/dynamic_repost/view_repost?dynamic_id=346409930135375313&;offset= 只能到五百多就停了(即只能獲取到最后轉(zhuǎn)發(fā)的五百多人,不排除重復(fù))。

中英版程序打包完成,直接運(yùn)行bat即可使用

下載地址(碼云倉庫):https://gitee.com/ikaros-521/bilibili_draw/raw/master/b%E7%AB%99%E8%BD%AC%E5%8F%91%E6%8A%BD%E5%A5%96.zip

運(yùn)行python腳本需要的條件:

1、連通的網(wǎng)絡(luò)

2、已安裝Python2并配置環(huán)境變量

3、Python腳本源碼

環(huán)境搭建:

網(wǎng)絡(luò)就不用我說了(〃'▽'〃) ?那么下面我們來安裝python吧。

Python官網(wǎng)有2個(gè)版本2和3,我們選擇2,因?yàn)檎Z法等方面會(huì)有所不同。

Python2下載:https://www.python.org/downloads/windows/

?


具體安裝教學(xué)可百度,或參考 教程:https://www.runoob.com/python/python-install.html

記得要配置環(huán)境變量。

?

環(huán)境變量配置方法:?“計(jì)算機(jī)”右鍵-> “屬性”->“高級(jí)系統(tǒng)設(shè)置”->“環(huán)境變量”-> 系統(tǒng)變量中找到“Path”->“編輯”->“新建”-> 將你python安裝的路徑粘貼進(jìn)去-> 全部“確認(rèn)”。

?

?

測試python是否配置完成。

按Win+R 鍵,輸入“cmd”,“確認(rèn)”。

?

成功運(yùn)行python命令即表示成功。

?

編寫腳本:

桌面右鍵 -> “新建”-> “文本文檔” -> 取名為 “抽獎(jiǎng).py”(不要隱藏文件擴(kuò)展名)

修改正確后的圖標(biāo)是

,而不是。


1、打開 “計(jì)算機(jī)”

2、點(diǎn)擊這個(gè)箭頭

?


3、選擇 “查看”


4、勾上 “文件擴(kuò)展名”


5、回到“桌面”,再次修改文件名。

?

感謝 Hack Inn大佬的腳本,下載網(wǎng)址:https://www.hackinn.com/index.php/archives/112/

文件建好后,我們貼入已經(jīng)寫好的代碼:

#!/usr/bin/env python

# -*- encoding: utf-8 -*-

"""

????Bilibili動(dòng)態(tài)轉(zhuǎn)發(fā)抽獎(jiǎng)腳本 V1.1

????Auteur:Poc Sir ??Bilibili:鳥云廠商

????Mon site Internet:https://www.hackinn.com

????Weibo:Poc-Sir Twitter:@rtcatc

????更新內(nèi)容: 1.增加了對(duì)畫冊(cè)類型動(dòng)態(tài)的支持。

"""

import os

import urllib2

import json

import sqlite3

import random

import webbrowser

import re

import time

from urlparse import *

def GetMiddleStr(content,startStr,endStr):

????startIndex = content.index(startStr)

????if startIndex>=0:

????????startIndex += len(startStr)

????endIndex = content.index(endStr)

????return content[startIndex:endIndex]

def GetUsers():

????global Bilibili_Key

????GetTotalRepost()

????Tmp_count = 0

????Bilibili_Key = 0

????DynamicAPI = "https://api.live.bilibili.com/dynamic_repost/v1/dynamic_repost/view_repost?dynamic_id=";+ Dynamic_id + "&offset="

????conn = sqlite3.connect('Bilibili_TMP.db')

????c = conn.cursor()

????while Tmp_count<Total_count:

????????Tmp_DynamicAPI = DynamicAPI + str(Tmp_count)

????????try:

????????????BiliJson = json.loads(GetMiddleStr(urllib2.urlopen(Tmp_DynamicAPI).read(),"comments\":",",\"total"))

????????????for BiliJson_dict in BiliJson:

????????????????Bilibili_UID = str(BiliJson_dict['uid'])

????????????????Bilibili_Uname = BiliJson_dict['uname']

????????????????Bilibili_Comment = BiliJson_dict['comment']

????????????????Bilibili_Sql = "INSERT or REPLACE into Bilibili (UID,Uname,Comment,ID) VALUES (" + Bilibili_UID + ", '" + Bilibili_Uname + "', '" + Bilibili_Comment + "', " + str(Bilibili_Key) + ")"

????????????????c.execute(Bilibili_Sql)

????????????????conn.commit()

????????????????Bilibili_Key = Bilibili_Key + 1

????????except:

????????????break

????????Tmp_count = Tmp_count + 20

????else:

????????Tmp_count = 0

????conn.close()

def GetTotalRepost():

????global Total_count

????global UP_UID

????DynamicAPI = "https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/get_dynamic_detail?dynamic_id="; + Dynamic_id

????BiliJson = json.loads(urllib2.urlopen(DynamicAPI).read())

????Total_count = BiliJson['data']['card']['desc']['repost']

????UP_UID = BiliJson['data']['card']['desc']['user_profile']['info']['uid']

def GetLuckyDog():

????Bilibili_Doge = random.randint(0,Bilibili_Key)

????conn = sqlite3.connect('Bilibili_TMP.db')

????c = conn.cursor()

????cursor = c.execute("SELECT UID from Bilibili where ID=" + str(Bilibili_Doge))

????res = cursor.fetchall()

????suc = True

????if len(res) > 0 :

????????suc = True

????????cursor.close()

????????conn.close()

????????conn2 = sqlite3.connect('Bilibili_TMP.db')

????????c2 = conn2.cursor()

????????info_cursor = c2.execute("SELECT UID,Uname,Comment from Bilibili where ID=" + str(Bilibili_Doge))

????????for row in info_cursor:

????????????print " 用戶ID: ", row[0]

????????????print " 用戶名: ", row[1]

????????????print " 轉(zhuǎn)發(fā)詳情: ", row[2], "\n"

????????????bilibili_open = raw_input(TellTime() + " 是否打開網(wǎng)頁給獲獎(jiǎng)用戶發(fā)送私信: (Y/N) ");

????????????if bilibili_open == "Y":

????????????????webbrowser.open("https://message.bilibili.com/#/whisper/mid"; + str(row[0]))

????????????elif bilibili_open == "y":

????????????????webbrowser.open("https://message.bilibili.com/#/whisper/mid"; + str(row[0]))

????????????elif bilibili_open == "Yes":

????????????????webbrowser.open("https://message.bilibili.com/#/whisper/mid"; + str(row[0]))

????????????elif bilibili_open == "yes":

????????????????webbrowser.open("https://message.bilibili.com/#/whisper/mid"; + str(row[0]))

????????????elif bilibili_open == "是":

????????????????webbrowser.open("https://message.bilibili.com/#/whisper/mid"; + str(row[0]))

????????????elif bilibili_open == "是的":

????????????????webbrowser.open("https://message.bilibili.com/#/whisper/mid"; + str(row[0]))

????????conn2.close()

????else:

????????suc = False

????????cursor.close()

????????conn.close()

????????GetLuckyDog()

def DeleteDatabase():

????DB_path = os.getcwd() + os.sep + "Bilibili_TMP.db"

????try:

????????os.remove(DB_path)

????????print TellTime() + " 正在清理緩存..."

????except:

????????print TellTime() + " 正在清理緩存..."

def CreateDatabase():

????conn = sqlite3.connect('Bilibili_TMP.db')

????c = conn.cursor()

????c.execute('''CREATE TABLE Bilibili

???????(UID INT PRIMARY KEY ????NOT NULL,

???????Uname ??????????TEXT ???NOT NULL,

???????Comment ??????????TEXT ???NOT NULL,

???????ID ???????????INT ?????NOT NULL);''')

????conn.commit()

????conn.close()

def GetDynamicid():

????s = raw_input(" 請(qǐng)粘貼您獲取到的網(wǎng)址: ")

????nums = re.findall(r'\d+', s)

????try:

???????bilibili_domain = urlparse(s)[1]

???????if bilibili_domain == "t.bilibili.com";:

???????????print TellTime() + " 為純文本類型動(dòng)態(tài) "

???????????return str(nums[0])

???????elif bilibili_domain == "h.bilibili.com";:

???????????bilibili_docid = "https://api.vc.bilibili.com/link_draw/v2/doc/dynamic_id?doc_id="; + str(nums[0])

???????????Dynamic_id = GetMiddleStr(urllib2.urlopen(bilibili_docid).read(),"dynamic_id\":\"","\"}}")

???????????print TellTime() + " 為畫冊(cè)類型動(dòng)態(tài) "

???????????return str(Dynamic_id)

????except:

???????print TellTime() + " 您輸入的網(wǎng)址有誤! "

???????exit()

def TellTime():

????localtime = "[" + str(time.strftime('%H:%M:%S',time.localtime(time.time()))) + "]"

????return localtime

if __name__ == '__main__':

????DeleteDatabase()

????print "+------------------------------------------------------------+"

????print "|在電腦端登錄Bilibli,點(diǎn)擊進(jìn)入個(gè)人主頁,再點(diǎn)擊動(dòng)態(tài),進(jìn)入動(dòng)態(tài)頁面|"

????print "|點(diǎn)擊對(duì)應(yīng)的動(dòng)態(tài)內(nèi)容,將獲取到的網(wǎng)址復(fù)制,并粘貼在下方: ??????|"

????print "+------------------------------------------------------------+\n"

????Dynamic_id = str(GetDynamicid())

????TellTime()

????print TellTime() + " 獲取動(dòng)態(tài)成功,ID為: " + Dynamic_id

????print TellTime() + " 正在獲取轉(zhuǎn)發(fā)數(shù)據(jù)中......"

????CreateDatabase()

????GetUsers()

????print TellTime() + " 獲取數(shù)據(jù)成功! "

????print TellTime() + " 中獎(jiǎng)用戶信息: \n"

????GetLuckyDog()

????DeleteDatabase()

? ? ? ? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ? ? ? ? ? ? ?

以上就是源碼部分。

貼入文件后 “保存” 退出。

?

按Win+R 鍵,輸入 “cmd”,進(jìn)入命令提示符,我們默認(rèn)路徑不在桌面,所以需要修改路徑。輸入“cd Desktop”,來到桌面,輸入“chcp 65001”,再輸入

set PYTHONIOENCODING=utf-8”。然后輸入“python 抽獎(jiǎng).py”運(yùn)行程序。

?

然后貼入你的動(dòng)態(tài)頁面的網(wǎng)址。進(jìn)入“b站”-> “動(dòng)態(tài)” -> 找到自己要抽獎(jiǎng)的那條動(dòng)態(tài)

-> 復(fù)制網(wǎng)址 -> 粘貼到命令行中 -> “回車”即可

?

?

運(yùn)行效果如下:

?

?

可能會(huì)碰到如下錯(cuò)誤,是因?yàn)橹形淖址脑颍梢允褂糜⑽陌妗?/p>

提供下解決思路,將中文字符串前后都加個(gè)英文空格。

然后命令行依然需要輸入

?“chcp 65001”

?“set PYTHONIOENCODING=utf-8”

然后運(yùn)行程序 “python 文件名.py”

?

?

英文版源碼:

#!/usr/bin/env python

# -*- encoding: utf-8 -*-

"""

????Bilibili動(dòng)態(tài)轉(zhuǎn)發(fā)抽獎(jiǎng)腳本 V1.1

????Auteur:Poc Sir ??Bilibili:鳥云廠商

????Mon site Internet:https://www.hackinn.com

????Weibo:Poc-Sir Twitter:@rtcatc

????更新內(nèi)容:1.增加了對(duì)畫冊(cè)類型動(dòng)態(tài)的支持。

"""

import os

import urllib2

import json

import sqlite3

import random

import webbrowser

import re

import time

from urlparse import *

def GetMiddleStr(content,startStr,endStr):

????startIndex = content.index(startStr)

????if startIndex>=0:

????????startIndex += len(startStr)

????endIndex = content.index(endStr)

????return content[startIndex:endIndex]

def GetUsers():

????global Bilibili_Key

????GetTotalRepost()

????Tmp_count = 0

????Bilibili_Key = 0

????DynamicAPI = "https://api.live.bilibili.com/dynamic_repost/v1/dynamic_repost/view_repost?dynamic_id=";+ Dynamic_id + "&offset="

????conn = sqlite3.connect('Bilibili_TMP.db')

????c = conn.cursor()

????while Tmp_count<Total_count:

????????Tmp_DynamicAPI = DynamicAPI + str(Tmp_count)

????????try:

????????????BiliJson = json.loads(GetMiddleStr(urllib2.urlopen(Tmp_DynamicAPI).read(),"comments\":",",\"total"))

????????????for BiliJson_dict in BiliJson:

????????????????Bilibili_UID = str(BiliJson_dict['uid'])

????????????????Bilibili_Uname = BiliJson_dict['uname']

????????????????Bilibili_Comment = BiliJson_dict['comment']

????????????????Bilibili_Sql = "INSERT or REPLACE into Bilibili (UID,Uname,Comment,ID) VALUES (" + Bilibili_UID + ", '" + Bilibili_Uname + "', '" + Bilibili_Comment + "', " + str(Bilibili_Key) + ")"

????????????????c.execute(Bilibili_Sql)

????????????????conn.commit()

????????????????Bilibili_Key = Bilibili_Key + 1

????????except:

????????????break

????????Tmp_count = Tmp_count + 20

????else:

????????Tmp_count = 0

????conn.close()

def GetTotalRepost():

????global Total_count

????global UP_UID

????DynamicAPI = "https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/get_dynamic_detail?dynamic_id="; + Dynamic_id

????BiliJson = json.loads(urllib2.urlopen(DynamicAPI).read())

????Total_count = BiliJson['data']['card']['desc']['repost']

????UP_UID = BiliJson['data']['card']['desc']['user_profile']['info']['uid']

def GetLuckyDog():

????Bilibili_Doge = random.randint(0,Bilibili_Key)

????conn = sqlite3.connect('Bilibili_TMP.db')

????c = conn.cursor()

????cursor = c.execute("SELECT UID from Bilibili where ID=" + str(Bilibili_Doge))

????res = cursor.fetchall()

????suc = True

????if len(res) > 0 :

????????suc = True

????????cursor.close()

????????conn.close()

????????conn2 = sqlite3.connect('Bilibili_TMP.db')

????????c2 = conn2.cursor()

????????info_cursor = c2.execute("SELECT UID,Uname,Comment from Bilibili where ID=" + str(Bilibili_Doge))

????????for row in info_cursor:

????????????print "user ID:", row[0]

????????????print "user name:", row[1], "\n"

????????????bilibili_open = raw_input(TellTime() + "Do you want to open a web page to send private messages to the winning users?:(Y/N)");

????????????if bilibili_open == "Y":

????????????????webbrowser.open("https://message.bilibili.com/#/whisper/mid"; + str(row[0]))

????????????elif bilibili_open == "y":

????????????????webbrowser.open("https://message.bilibili.com/#/whisper/mid"; + str(row[0]))

????????????elif bilibili_open == "Yes":

????????????????webbrowser.open("https://message.bilibili.com/#/whisper/mid"; + str(row[0]))

????????????elif bilibili_open == "yes":

????????????????webbrowser.open("https://message.bilibili.com/#/whisper/mid"; + str(row[0]))

????????????elif bilibili_open == "是":

????????????????webbrowser.open("https://message.bilibili.com/#/whisper/mid"; + str(row[0]))

????????????elif bilibili_open == "是的":

????????????????webbrowser.open("https://message.bilibili.com/#/whisper/mid"; + str(row[0]))

????????conn2.close()

????else:

????????suc = False

????????cursor.close()

????????conn.close()

????????GetLuckyDog()

def DeleteDatabase():

????DB_path = os.getcwd() + os.sep + "Bilibili_TMP.db"

????try:

????????os.remove(DB_path)

????????print TellTime() + "Cleaning up cache..."

????except:

????????print TellTime() + "Cleaning up cache..."

def CreateDatabase():

????conn = sqlite3.connect('Bilibili_TMP.db')

????c = conn.cursor()

????c.execute('''CREATE TABLE Bilibili

???????(UID INT PRIMARY KEY ????NOT NULL,

???????Uname ??????????TEXT ???NOT NULL,

???????Comment ??????????TEXT ???NOT NULL,

???????ID ???????????INT ?????NOT NULL);''')

????conn.commit()

????conn.close()

def GetDynamicid():

????s = raw_input("Please paste the website you get:")

????nums = re.findall(r'\d+', s)

????try:

???????bilibili_domain = urlparse(s)[1]

???????if bilibili_domain == "t.bilibili.com";:

???????????print TellTime() + "Dynamic for plain text type"

???????????return str(nums[0])

???????elif bilibili_domain == "h.bilibili.com";:

???????????bilibili_docid = "https://api.vc.bilibili.com/link_draw/v2/doc/dynamic_id?doc_id="; + str(nums[0])

???????????Dynamic_id = GetMiddleStr(urllib2.urlopen(bilibili_docid).read(),"dynamic_id\":\"","\"}}")

???????????print TellTime() + "Dynamic for album type"

???????????return str(Dynamic_id)

????except:

???????print TellTime() + "The URL you entered is incorrect!"

???????exit()

def TellTime():

????localtime = "[" + str(time.strftime('%H:%M:%S',time.localtime(time.time()))) + "]"

????return localtime

if __name__ == '__main__':

????DeleteDatabase()

????print "+---------------------------------------------------------------------------------------+"

????print "|PC login Bilibli,in home page,Click on the news again,Enter the dynamic page ?????????|"

????print "|Click the corresponding dynamic content, copy and paste the obtained URL below: ??????|"

????print "+---------------------------------------------------------------------------------------+\n"

????Dynamic_id = str(GetDynamicid())

????TellTime()

????print TellTime() + "Get dynamic success with ID:" + Dynamic_id

????print TellTime() + "Getting forwarding data......"

????CreateDatabase()

????GetUsers()

????print TellTime() + "Data acquisition successful!"

????print TellTime() + "Winning user information:\n"

????GetLuckyDog()

DeleteDatabase()

?

???????????????????????????????????????????????????????????????????????

使用操作是不需要修改編碼,直接win+R,運(yùn)行cmd,然后cd到桌面,運(yùn)行python文件,粘貼入你的動(dòng)態(tài)頁面網(wǎng)址,就可以完成抽獎(jiǎng)了。之后可以選擇是否私信,很方便。再次感謝Hack Inn大佬提供的源碼。

?

?

補(bǔ)充說明:

如需幫助可聯(lián)系up

b站:Love丶伊卡洛斯

QQ: 327209194

QQ群:511921385

?

侵刪同樣聯(lián)系方式如上。


B站動(dòng)態(tài)轉(zhuǎn)發(fā)抽獎(jiǎng)教程的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國家法律
昌乐县| 福泉市| 平昌县| 交城县| 栖霞市| 神木县| 泸州市| 蒲城县| 肥乡县| 当涂县| 江孜县| 观塘区| 定陶县| 万山特区| 修水县| 资源县| 瑞丽市| 宜兰市| 邮箱| 安新县| 廊坊市| 左云县| 鲜城| 日喀则市| 界首市| 武胜县| 青川县| 巴东县| 南阳市| 顺昌县| 铁岭县| 阿拉尔市| 德钦县| 同心县| 合山市| 绍兴县| 和平区| 电白县| 吕梁市| 陇西县| 邹平县|