Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@pcmid
Created September 20, 2018 06:44
Show Gist options
  • Star 75 You must be signed in to star a gist
  • Fork 19 You must be signed in to fork a gist
  • Save pcmid/5818b1165bc3f5f2088e19299278a613 to your computer and use it in GitHub Desktop.
Save pcmid/5818b1165bc3f5f2088e19299278a613 to your computer and use it in GitHub Desktop.
获取有效的百度app_id
from __future__ import print_function
import requests
import threading
import sys
def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
class GetterTread(threading.Thread):
def __init__(self, thread_id, app_id, times=1000):
threading.Thread.__init__(self)
self.__thread_id = thread_id
self.__URL = "http://pcs.baidu.com/rest/2.0/pcs/file?app_id={}&method=list&path=%2F"
with open("./BDUSS.txt") as f:
BDUSS = f.readline()
self.__COOKIES = {"BDUSS": BDUSS}
self.app_id = app_id
self.times = times
def run(self):
current_id = self.app_id
while current_id - self.app_id < self.times: # 250000:
url = self.__URL.format(current_id)
try:
r = requests.get(url, cookies=self.__COOKIES)
if r.status_code == 200:
print(current_id)
except Exception:
eprint("Exception: " + str(current_id))
current_id += 1
# print("id " + str(self.__thread_id) + " over")
if __name__ == '__main__':
start_app_id = 300000
times = 1000
threads_list = []
while start_app_id < 500000:
thread = GetterTread(start_app_id, start_app_id, times)
thread.start()
threads_list.append(thread)
start_app_id += times
# print("size: " + str(len(threads_list)))
for thread in threads_list:
thread.join()
371067
419237
323309
312618
310646
309847
421937
@oooceanzh
Copy link

怎么用啊

@469312306
Copy link

1.是不是要在根目录下创建一个BDUSS.txt文件?
2.获取到正常的app_id是只会print出来还是会写入BDUSS.txt文件中?
谢谢

@pcmid
Copy link
Author

pcmid commented Nov 4, 2018

@bilibili-zh @469312306

1.首先创建一个BDUSS.txt 里面填上你的BDUSS
2.执行 ./BaiduPCS-appid-getter.py > result.txt

@liangzhdp
Copy link

./BaiduPCS-appid-getter.py:行1: from:未找到命令
第一行就出错?

@marklove5102
Copy link

新手pip install requests

@marklove5102
Copy link

id([\s\s])(\d*)? over 如果不幸打开了#输出 用这个正则替换掉。。。 用对比器对比找相同的就好了。。。
3-4 就是 result.txt 提供的 5以上自己来吧。

@landall
Copy link

landall commented Sep 23, 2019

371067 已经403了。

我刚才测了一下非全局的那些appid,发现有的appid居然可以upload,不支持download。不知道未来是否需要更多分支的测试
download api的情况:
419237 失败
323309 失败
312618 失败
310646 失败
309847 失败
421937 失败

266719是成功的,所以测试程序应该是可靠的。

@landall
Copy link

landall commented Sep 23, 2019

我自己的理解是,完整的测试过程应该是:

  1. list / 返回200的,测试download。(upload我的测试是都能过)
  2. list / 报错的(有时候需要执行第二次,百度自己会抽风),去/apps目录里找到创建apps等于待测试的那个folder,然后进去测试download。

这样能找出来可以用的全局appid和/apps/目录可用的appid。
不过传说的非全局appid不限速应该也是过去时了,我测试的速度全是80KB/s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment