├── README.md ├── bilibili_proxy.py ├── bilibili_proxypool.py ├── image ├── image.jpeg └── proxy.jpeg └── proxy.txt /README.md: -------------------------------------------------------------------------------- 1 | # **已知问题** # 2 | **目前每次请求都会更换useragent,如果不起作用可以修改对应部分代码** 3 | 4 | **已知第二种方法用700个代理刷取播放量实际只能到150左右,不确定是什么问题** 5 | 6 | **各位可以尝试单独用https,http代理,修改headers里的参数,请求的间隔时间等等方法来寻找刷播放量的最佳方式** 7 | 8 | ***有任何问题请提issue,也欢迎分享改进方法*** 9 | ## [通过代理池刷播放量](bilibili_proxypool.py) 10 | 11 | 12 | ***所需安装依赖*** 13 | ```python 14 | pip install requests 15 | ``` 16 | 17 | **使用**:只需修改以下部分,运行即可 18 | ![image](image/image.jpeg) 19 | 20 | 21 | ## [通过现有的代理刷播放量](bilibili_proxy.py) 22 | 使用前请确保[proxy.txt](proxy.txt)中有HTTP代理 23 | 24 | 每次运行都会去除不可用代理,添加代理可直接在末尾粘贴 25 | 26 | ***所需安装依赖*** 27 | ```python 28 | pip install fake_useragent 29 | ``` 30 | ```python 31 | pip install requests 32 | ``` 33 | 34 | 35 | **代理格式** 36 | 37 | ![image](image/proxy.jpeg) 38 | 39 | ## 免费代理 40 | **[checkerproxy](https://checkerproxy.net/getAllProxy)** 41 | 42 | 43 | 44 | ## 代理池 45 | [jhao104/proxy_pool](https://github.com/jhao104/proxy_pool) 46 | -------------------------------------------------------------------------------- /bilibili_proxy.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import time 3 | import requests 4 | import threading 5 | from fake_useragent import UserAgent 6 | 7 | 8 | #使用前确保proxy.txt中有可用代理 9 | 10 | 11 | #视频bv号放这里,格式如下 12 | 13 | bvid=["xxxx","xxxx"] 14 | 15 | 16 | 17 | lock=threading.Lock() 18 | 19 | 20 | url = "http://api.bilibili.com/x/click-interface/click/web/h5" 21 | 22 | 23 | headers = { 24 | 'User-Agent':"", 25 | 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', 26 | 'Accept-Language': 'zh-CN,zh;q=0.9', 27 | 'Accept-Encoding': 'gzip, deflate, br', 28 | 'Origin': 'https://www.bilibili.com', 29 | 'Connection': 'keep-alive' 30 | } 31 | 32 | reqdata = [] 33 | for bv in bvid: 34 | stime = str(int(time.time())) 35 | print("正在获取data,请耐心等待。。。") 36 | while True: 37 | resp = requests.get("http://api.bilibili.com/x/web-interface/view?bvid={}".format(bv),headers=headers) 38 | resp_json = resp.json() 39 | if "data" in resp_json: 40 | getdata = resp_json["data"] 41 | break 42 | data= { 43 | 'aid':getdata["aid"], 44 | 'cid':getdata["cid"], 45 | "bvid": bv, 46 | 'part':'1', 47 | 'mid':getdata["owner"]["mid"], 48 | 'lv':'6', 49 | "stime" :stime, 50 | 'jsonp':'jsonp', 51 | 'type':'3', 52 | 'sub_type':'0', 53 | 'title': getdata["title"] 54 | } 55 | reqdata.append(data) 56 | 57 | 58 | 59 | 60 | 61 | def process_lines(lines): 62 | # 在这里处理行 63 | for line in lines: 64 | ip=line.strip() 65 | proxies = { 66 | 'http': 'http://' + ip, 67 | } 68 | 69 | try: 70 | for data in reqdata: 71 | stime = str(int(time.time())) 72 | data["stime"] = stime 73 | headers["User-Agent"] = UserAgent().random 74 | headers["referer"] = "http://www.bilibili.com/video/{}/".format(data.get("bvid")) 75 | requests.post(url,headers=headers,data=data,proxies=proxies,timeout=2) 76 | 77 | lock.acquire() 78 | with open('proxy.txt', 'a', encoding='utf-8') as f: 79 | f.write(ip+"\n") 80 | f.flush() 81 | lock.release() 82 | 83 | 84 | except Exception as e: 85 | print("代理连接超时") 86 | print("done {}".format(ip)) 87 | 88 | 89 | 90 | def run(): 91 | with open('proxy.txt', 'r', encoding='utf-8') as f: 92 | if f.read() == "": 93 | # 如果文件为空,就不执行 94 | print("proxy.txt中无代理") 95 | return 96 | 97 | 98 | with open('proxy.txt', 'r', encoding='utf-8') as f: 99 | lines = f.readlines() 100 | # 清空文件 101 | with open('proxy.txt', 'w', encoding='utf-8') as f: 102 | f.write("") 103 | 104 | # 计算每个线程需要处理的行数 105 | if len(lines) < 50: 106 | threadnum=len(lines) 107 | lines_per_thread = len(lines)//len(lines) 108 | else: 109 | threadnum=50 110 | lines_per_thread = len(lines) // 50 111 | 112 | threads = [] 113 | 114 | 115 | for i in range(threadnum): 116 | # 计算这个线程需要处理的行的起始和结束索引 117 | start = i * lines_per_thread 118 | end = start + lines_per_thread if i < (threadnum-1) else None # 最后一个线程处理剩余的所有行 119 | 120 | # 创建一个新线程来处理这些行 121 | thread = threading.Thread(target=process_lines, args=(lines[start:end],)) 122 | 123 | thread.start() 124 | threads.append(thread) 125 | 126 | 127 | run() 128 | 129 | -------------------------------------------------------------------------------- /bilibili_proxypool.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import time 3 | 4 | 5 | #通过代理池项目刷播放量,如果没有部署此项目,可移步bilibili_proxy.py 6 | 7 | #视频bv号放这里,格式如下 8 | 9 | bvid=["xxxx","xxxx"] 10 | 11 | 12 | #代理池地址,项目可见https://github.com/jhao104/proxy_pool 13 | 14 | getproxy = "http://127.0.0.1:5010/get/" 15 | deleteproxy = "http://127.0.0.1:5010/delete/?proxy={}" 16 | proxynum="http://127.0.0.1:5010/count" 17 | 18 | 19 | 20 | url = "http://api.bilibili.com/x/click-interface/click/web/h5" 21 | 22 | 23 | headers = { 24 | 'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36', 25 | 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', 26 | 'Accept-Language': 'zh-CN,zh;q=0.9', 27 | 'Accept-Encoding': 'gzip, deflate, br', 28 | 'Origin': 'https://www.bilibili.com', 29 | 'Connection': 'keep-alive' 30 | } 31 | 32 | reqdata = [] 33 | for bv in bvid: 34 | stime = str(int(time.time())) 35 | 36 | while True: 37 | resp = requests.get("http://api.bilibili.com/x/web-interface/view?bvid={}".format(bv),headers=headers) 38 | resp_json = resp.json() 39 | if "data" in resp_json: 40 | getdata = resp_json["data"] 41 | break 42 | 43 | data= { 44 | 'aid':getdata["aid"], 45 | 'cid':getdata["cid"], 46 | "bvid": bv, 47 | 'part':'1', 48 | 'mid':getdata["owner"]["mid"], 49 | 'lv':'6', 50 | "stime" :stime, 51 | 'jsonp':'jsonp', 52 | 'type':'3', 53 | 'sub_type':'0', 54 | 'title': getdata["title"] 55 | } 56 | reqdata.append(data) 57 | 58 | 59 | 60 | def run(): 61 | num=0 62 | while int(requests.get(proxynum).json().get("count")) != 0: 63 | 64 | resp=requests.get(getproxy).json().get("proxy") 65 | for data in reqdata: 66 | 67 | try: 68 | stime = str(int(time.time())) 69 | data["stime"] = stime 70 | headers["referer"] = "http://www.bilibili.com/video/{}/".format(data.get("bvid")) 71 | 72 | proxy = { 73 | "http": "http://{}".format(resp) 74 | } 75 | 76 | requests.post(url,headers=headers,data=data,proxies=proxy,timeout=5) 77 | 78 | except Exception as e: 79 | print("代理连接超时") 80 | 81 | requests.get(deleteproxy.format(resp)) 82 | num+=1 83 | print("done {}".format(num)) 84 | 85 | print("无可用代理") 86 | 87 | run() 88 | 89 | -------------------------------------------------------------------------------- /image/image.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xu0329/bilibili_proxy/382afef03c635f439ff1f53c944d2e8803f35775/image/image.jpeg -------------------------------------------------------------------------------- /image/proxy.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xu0329/bilibili_proxy/382afef03c635f439ff1f53c944d2e8803f35775/image/proxy.jpeg -------------------------------------------------------------------------------- /proxy.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xu0329/bilibili_proxy/382afef03c635f439ff1f53c944d2e8803f35775/proxy.txt --------------------------------------------------------------------------------