分类 默认分类 下的文章

用上了chromium.但是因为没有API KEY,导致无法登录浏览器,无法同步书签栏.

参考这个文章,https://gist.github.com/cvan/44a6d60457b20133191bd7b104f9dcc4
申请属于自己的API KEY.
关键点就是上面URL里面提到的7和10.
申请好之后

管理员的命令行CMD下输入.
setx GOOGLE_API_KEY AIzaSyBwIKtzAADbKEXxKFki4-5335pRp6Dggq0
setx GOOGLE_DEFAULT_CLIENT_ID 461596714253-5hv1lml8olmag1n02boogjp1krnp95k4.apps.googleusercontent.com
setx GOOGLE_DEFAULT_CLIENT_SECRET qzx3tM5Z3Ole3UiBZfe7GVSw
上面这几个是我自己申请的

出错提示“获取目录下的文件列表: 遇到错误, 远端服务器返回错误, 代码: 4, 消息: No permission to do this operation ”。
解决办法:更改APPID。
打开C:/Users/Administrator/AppData/Roaming/BaiduPCS-Go/pcs_config.json

获取可用APPID的脚本


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()

莫名其妙出了错.
复杂的方式:
创建恢复U盘.还要官网下订单,特殊的客户端下载.下载完要14个G.压到U盘里.

简单的方式:
重启,
Enter,进入快速选择菜单.
F11,进入恢复模式.
RESET.

两种方式.

1,requests


#!/usr/bin/env python
# -- coding: utf-8 --
import requests
import ssl
requests.packages.urllib3.disable_warnings()
url = 'https://www.douban.com/'
c = requests.get(url,timeout=5,verify=False)
html = c.text
print html
#print html.encode("GBK", 'ignore'); 
exit()

如果是用cmd下面调试,要用encode gbk.

2,pycurl


#!/usr/bin/env python
# -- coding: utf-8 --
import pycurl
import certifi
url = 'https://202.55.9.30/'
c = pycurl.Curl()
c.setopt(c.URL, url)
c.setopt(pycurl.CAINFO, certifi.where())
# Follow redirect.
c.setopt(c.FOLLOWLOCATION, True)
c.setopt(c.SSL_VERIFYHOST,False);
c.setopt(c.SSL_VERIFYPEER,False);
html = c.perform()
c.close()
print html;
#print html.encode("GBK", 'ignore');
exit()

4,urllib2


#!/usr/bin/env python
# -- coding: utf-8 --
import urllib2
import ssl

ssl._create_default_https_context = ssl._create_unverified_context
f = urllib2.urlopen("https://202.55.9.30/")
html = f.read()
f.close()
print html