Skip to content

Instantly share code, notes, and snippets.

@upbit
Forked from ZipFile/README.md
Last active Sep 13, 2021
Embed
What would you like to do?
Pixiv OAuth Flow (with Selenium)

Retrieving Auth Token (with Selenium)

  1. Setup, install Selenium/ChromeDriver
pip install selenium
# download chromedriver from https://chromedriver.storage.googleapis.com/index.html?path=91.0.4472.101/
# eg: wget https://chromedriver.storage.googleapis.com/91.0.4472.101/chromedriver_mac64.zip && unzip chromedriver_mac64.zip
  1. unzip chromedriver (due to Gatekeeper, run it if you use MacOS):
+
|-> pixiv_auth.py
\-> chromedriver      <- place to here
  1. Run the command:
python pixiv_auth.py login

This will open the browser with Pixiv login page.

If you did everything right and Pixiv did not change their auth flow, pair of auth_token and refresh_token should be displayed.

After entering the password, wait for a while, chrome will disappear, and the following information will be output in the console window:

❯ python3 pixiv_auth.py login
[INFO] Get code: 3s3Xc075wd7njPLJBXgXc4qS-...
access_token: Fp9WaXhNapC8myQltgEn...
refresh_token: uXooTT7xz9v4mflnZqJ...
expires_in: 3600

Refresh Tokens

python pixiv_auth.py refresh OLD_REFRESH_TOKEN

使用方法:

  1. 下载 pixiv_auth.py 脚本,以及 chromedriver(放在脚本目录)
  2. pip install selenium
  3. python pixiv_auth.py login

成功后会在窗口内自动显示refresh_token,保存起来以后通过 api.auth(refresh_token=REFRESH_TOKEN) 登录

注:如果在墙内访问,请手动设置 REQUESTS_KWARGS.proxies 的代理,不然获取code后无法正确提交请求到Pixiv (现象是 [INFO] Get code: xxxxx 后一直卡住,未requests配置代理即可)

#!/usr/bin/env python
import time
import json
import re
import requests
from argparse import ArgumentParser
from base64 import urlsafe_b64encode
from hashlib import sha256
from pprint import pprint
from secrets import token_urlsafe
from sys import exit
from urllib.parse import urlencode
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
# Latest app version can be found using GET /v1/application-info/android
USER_AGENT = "PixivIOSApp/7.13.3 (iOS 14.6; iPhone13,2)"
REDIRECT_URI = "https://app-api.pixiv.net/web/v1/users/auth/pixiv/callback"
LOGIN_URL = "https://app-api.pixiv.net/web/v1/login"
AUTH_TOKEN_URL = "https://oauth.secure.pixiv.net/auth/token"
CLIENT_ID = "MOBrBDS8blbauoSck0ZfDbtuzpyT"
CLIENT_SECRET = "lsACyCD94FhDUtGTXi3QzcFE2uU1hqtDaKeqrdwj"
REQUESTS_KWARGS = {
# 'proxies': {
# 'https': 'http://127.0.0.1:1087',
# },
# 'verify': False
}
def s256(data):
"""S256 transformation method."""
return urlsafe_b64encode(sha256(data).digest()).rstrip(b"=").decode("ascii")
def oauth_pkce(transform):
"""Proof Key for Code Exchange by OAuth Public Clients (RFC7636)."""
code_verifier = token_urlsafe(32)
code_challenge = transform(code_verifier.encode("ascii"))
return code_verifier, code_challenge
def print_auth_token_response(response):
data = response.json()
try:
access_token = data["access_token"]
refresh_token = data["refresh_token"]
except KeyError:
print("error:")
pprint(data)
exit(1)
print("access_token:", access_token)
print("refresh_token:", refresh_token)
print("expires_in:", data.get("expires_in", 0))
def login():
caps = DesiredCapabilities.CHROME.copy()
caps["goog:loggingPrefs"] = {"performance": "ALL"} # enable performance logs
driver = webdriver.Chrome("./chromedriver", desired_capabilities=caps)
code_verifier, code_challenge = oauth_pkce(s256)
login_params = {
"code_challenge": code_challenge,
"code_challenge_method": "S256",
"client": "pixiv-android",
}
print("[INFO] Gen code_verifier:", code_verifier)
driver.get(f"{LOGIN_URL}?{urlencode(login_params)}")
while True:
# wait for login
if driver.current_url[:40] == "https://accounts.pixiv.net/post-redirect":
break
time.sleep(1)
# filter code url from performance logs
code = None
for row in driver.get_log('performance'):
data = json.loads(row.get("message", {}))
message = data.get("message", {})
if message.get("method") == "Network.requestWillBeSent":
url = message.get("params", {}).get("documentURL")
if url[:8] == "pixiv://":
code = re.search(r'code=([^&]*)', url).groups()[0]
break
driver.close()
print("[INFO] Get code:", code)
response = requests.post(
AUTH_TOKEN_URL,
data={
"client_id": CLIENT_ID,
"client_secret": CLIENT_SECRET,
"code": code,
"code_verifier": code_verifier,
"grant_type": "authorization_code",
"include_policy": "true",
"redirect_uri": REDIRECT_URI,
},
headers={
"user-agent": USER_AGENT,
"app-os-version": "14.6",
"app-os": "ios",
},
**REQUESTS_KWARGS
)
print_auth_token_response(response)
def refresh(refresh_token):
response = requests.post(
AUTH_TOKEN_URL,
data={
"client_id": CLIENT_ID,
"client_secret": CLIENT_SECRET,
"grant_type": "refresh_token",
"include_policy": "true",
"refresh_token": refresh_token,
},
headers={
"user-agent": USER_AGENT,
"app-os-version": "14.6",
"app-os": "ios",
},
**REQUESTS_KWARGS
)
print_auth_token_response(response)
def main():
parser = ArgumentParser()
subparsers = parser.add_subparsers()
parser.set_defaults(func=lambda _: parser.print_usage())
login_parser = subparsers.add_parser("login")
login_parser.set_defaults(func=lambda _: login())
refresh_parser = subparsers.add_parser("refresh")
refresh_parser.add_argument("refresh_token")
refresh_parser.set_defaults(func=lambda ns: refresh(ns.refresh_token))
args = parser.parse_args()
args.func(args)
if __name__ == "__main__":
main()
@bottomash29

This comment has been minimized.

Copy link

@bottomash29 bottomash29 commented Feb 18, 2021

需要其他的更改吗?
image
是我自己的问题吗,我不太懂,感谢大佬。

@upbit

This comment has been minimized.

Copy link
Owner Author

@upbit upbit commented Feb 19, 2021

需要其他的更改吗?
image
是我自己的问题吗,我不太懂,感谢大佬。

requests库也是必须的,需要先安装下
pip install requests

@m25u

This comment has been minimized.

Copy link

@m25u m25u commented Feb 20, 2021

image
你好,我本地运行这一步403了,挂了代理也不起效果,是因为IP问题吗

@upbit

This comment has been minimized.

Copy link
Owner Author

@upbit upbit commented Feb 20, 2021

原始脚本能不能work?https://gist.github.com/ZipFile/c9ebedb224406f4f11845ab700124362

这个后面一次请求,是通过requests发起的,除了selenium的还要额外的增加requests代理(参考 https://gist.github.com/ZipFile/c9ebedb224406f4f11845ab700124362#gistcomment-3636957

@m25u

This comment has been minimized.

Copy link

@m25u m25u commented Feb 20, 2021

原始脚本能不能work?https://gist.github.com/ZipFile/c9ebedb224406f4f11845ab700124362

这个后面一次请求,是通过requests发起的,因此要额外的增加代理(参考 https://gist.github.com/ZipFile/c9ebedb224406f4f11845ab700124362#gistcomment-3636957)

增加了额外代理,可能我用的质量不佳,我再研究研究,多谢大佬

@sayri23

This comment has been minimized.

Copy link

@sayri23 sayri23 commented Feb 24, 2021

带佬求解,小白一枚
5H22Q%LI@UTUA4}}9I_K2~W

@sayri23

This comment has been minimized.

Copy link

@sayri23 sayri23 commented Feb 24, 2021

带佬求解,小白一枚
5H22Q%LI@UTUA4}}9I_K2~W

是py版本不同而语法也不同的原因吗?

@upbit

This comment has been minimized.

Copy link
Owner Author

@upbit upbit commented Feb 24, 2021

对,换python3。f"" 是python3的语法,可以换成 "" % ()

@sayri23

This comment has been minimized.

Copy link

@sayri23 sayri23 commented Feb 24, 2021

对,换python3。f"" 是python3的语法,可以换成 "" % ()

换了py3就成这个错误了
5G_M2@Q54J2DBU$4%39V6QC

@upbit

This comment has been minimized.

Copy link
Owner Author

@upbit upbit commented Feb 24, 2021

要下载chromedriver放在脚本一起:https://chromedriver.storage.googleapis.com/88.0.4324.96/
参考第二步

@sayri23

This comment has been minimized.

Copy link

@sayri23 sayri23 commented Feb 24, 2021

要下载chromedriver放在脚本一起:https://chromedriver.storage.googleapis.com/88.0.4324.96/
参考第二步

又出问题了(捂脸)
B5A(TNT 3Y3YG%JK}AXMD_R

@upbit

This comment has been minimized.

Copy link
Owner Author

@upbit upbit commented Feb 24, 2021

权限问题 chmod +x chromedriver。另外,可以先手动运行下这个bin确保能启动chrome

@sayri23

This comment has been minimized.

Copy link

@sayri23 sayri23 commented Feb 24, 2021

权限问题 chmod +x chromedriver。另外,可以先手动运行下这个bin确保能启动chrome

加了777权限还是不行,错误如下(这个是bin文件吗,没有拓展名)
Traceback (most recent call last):
File "pixiv_auth.py", line 141, in
main()
File "pixiv_auth.py", line 137, in main
args.func(args)
File "pixiv_auth.py", line 132, in
login_parser.set_defaults(func=lambda _: login())
File "pixiv_auth.py", line 63, in login
driver = webdriver.Chrome("./chromedriver", desired_capabilities=caps)
File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/chrome/webdriver.py", line 76, in init
RemoteWebDriver.init(
File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in init
self.start_session(capabilities, browser_profile)
File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

@upbit

This comment has been minimized.

Copy link
Owner Author

@upbit upbit commented Mar 2, 2021

The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.

这里其实有说明,机器上没有Chrome /usr/bin/google-chrome,所以driver不能运行。这个你可以参考网上关于chromedriver的教程,看看如何配置基本环境

@yryd

This comment has been minimized.

Copy link

@yryd yryd commented Apr 1, 2021

image
image
请问这个错误怎么处理,已经输出code了,在出tocken时大约等了5分钟后这个报错

@upbit

This comment has been minimized.

Copy link
Owner Author

@upbit upbit commented Jun 26, 2021

image
image
请问这个错误怎么处理,已经输出code了,在出tocken时大约等了5分钟后这个报错

这个是因为提交code的代码需要挂代理。更新了下脚本,设置REQUESTS_KWARGS.proxies的代理即可

@Thomitics

This comment has been minimized.

Copy link

@Thomitics Thomitics commented Jul 2, 2021

Traceback (most recent call last):
  File "C:\Python39\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "C:\Python39\lib\site-packages\urllib3\connectionpool.py", line 382, in _make_request
    self._validate_conn(conn)
  File "C:\Python39\lib\site-packages\urllib3\connectionpool.py", line 1010, in _validate_conn
    conn.connect()
  File "C:\Python39\lib\site-packages\urllib3\connection.py", line 411, in connect
    self.sock = ssl_wrap_socket(
  File "C:\Python39\lib\site-packages\urllib3\util\ssl_.py", line 449, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(
  File "C:\Python39\lib\site-packages\urllib3\util\ssl_.py", line 493, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "C:\Python39\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "C:\Python39\lib\ssl.py", line 1040, in _create
    self.do_handshake()
  File "C:\Python39\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python39\lib\site-packages\requests\adapters.py", line 439, in send
    resp = conn.urlopen(
  File "C:\Python39\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "C:\Python39\lib\site-packages\urllib3\util\retry.py", line 532, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "C:\Python39\lib\site-packages\urllib3\packages\six.py", line 769, in reraise
    raise value.with_traceback(tb)
  File "C:\Python39\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "C:\Python39\lib\site-packages\urllib3\connectionpool.py", line 382, in _make_request
    self._validate_conn(conn)
  File "C:\Python39\lib\site-packages\urllib3\connectionpool.py", line 1010, in _validate_conn
    conn.connect()
  File "C:\Python39\lib\site-packages\urllib3\connection.py", line 411, in connect
    self.sock = ssl_wrap_socket(
  File "C:\Python39\lib\site-packages\urllib3\util\ssl_.py", line 449, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(
  File "C:\Python39\lib\site-packages\urllib3\util\ssl_.py", line 493, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "C:\Python39\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "C:\Python39\lib\ssl.py", line 1040, in _create
    self.do_handshake()
  File "C:\Python39\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
urllib3.exceptions.ProtocolError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Thomitics\Desktop\az\pixiv_auth.py", line 157, in <module>
    main()
  File "C:\Users\Thomitics\Desktop\az\pixiv_auth.py", line 153, in main
    args.func(args)
  File "C:\Users\Thomitics\Desktop\az\pixiv_auth.py", line 148, in <lambda>
    login_parser.set_defaults(func=lambda _: login())
  File "C:\Users\Thomitics\Desktop\az\pixiv_auth.py", line 101, in login
    response = requests.post(
  File "C:\Python39\lib\site-packages\requests\api.py", line 119, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "C:\Python39\lib\site-packages\requests\api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Python39\lib\site-packages\requests\sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Python39\lib\site-packages\requests\sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "C:\Python39\lib\site-packages\requests\adapters.py", line 498, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

已经输出code了,这个怎么办

REQUESTS_KWARGS.proxies的代理已经设置了

@upbit

This comment has been minimized.

Copy link
Owner Author

@upbit upbit commented Jul 3, 2021

ssl.py FileNotFoundError: [Errno 2] No such file or directory 看起来是SSL的问题,proxies里增加下verify='false'去掉证书校验

https://stackoverflow.com/questions/39048446/python-requests-library-ssl-error-errno-2-no-such-file-or-directory

@Thomitics

This comment has been minimized.

Copy link

@Thomitics Thomitics commented Jul 3, 2021

ssl.py FileNotFoundError: [Errno 2] No such file or directory 看起来是SSL的问题,proxies里增加下verify='false'去掉证书校验

https://stackoverflow.com/questions/39048446/python-requests-library-ssl-error-errno-2-no-such-file-or-directory

好像没用……

@ybygjylj

This comment has been minimized.

Copy link

@ybygjylj ybygjylj commented Jul 25, 2021

ubuntu@instance-20210724-2310:~$ python3 pixiv_auth.py login
Traceback (most recent call last): File "pixiv_auth.py", line 156, in main()
File "pixiv_auth.py", line 152, in main
args.func(args) File "pixiv_auth.py", line 147, in login_parser.set_defaults(func=lambda _: login())
File "pixiv_auth.py", line 67, in login
driver = webdriver.Chrome("./chromedriver", desired_capabilities=caps) File "/home/ubuntu/.local/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 76, in init
RemoteWebDriver.init( File "/home/ubuntu/.local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in init
self.start_session(capabilities, browser_profile) File "/home/ubuntu/.local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters) File "/home/ubuntu/.local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/home/ubuntu/.local/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

ubuntu@instance-20210724-2310:~$ ls
OPQ-SetuBot
chromedriver
chromedriver_linux64.zip
go
google-chrome-stable_current_amd64.deb
install.sh
pixiv_auth.py
use.go

@love-syl

This comment has been minimized.

Copy link

@love-syl love-syl commented Aug 26, 2021

请问最后这一步是什么意思,没怎么看懂

@love-syl

This comment has been minimized.

Copy link

@love-syl love-syl commented Aug 26, 2021

如最后这一步是什么意思,没怎么看懂

这句话 ‘保存起来以后通过 api.auth(refresh_token=REFRESH_TOKEN) 登录’

@eggplants

This comment has been minimized.

Copy link

@eggplants eggplants commented Aug 28, 2021

I have made this script more easier to run and available from another program. Also I have prepared a headless mode so it can work in environments without GUI.
Install: pip install gppt
See: https://github.com/eggplants/get-pixivpy-token

@eggplants

This comment has been minimized.

Copy link

@eggplants eggplants commented Sep 12, 2021

@wzxyisme I solved:

+ options = webdriver.ChromeOptions()
+ options.add_argument('--no-sandbox')
+ options.add_argument('--disable-dev-shm-usage')
+
- driver = webdriver.Chrome("./chromedriver", desired_capabilities=caps)
+ driver = webdriver.Chrome("./chromedriver", desired_capabilities=caps, options=options)

ref: https://stackoverflow.com/questions/50642308

@smallsay

This comment has been minimized.

Copy link

@smallsay smallsay commented Sep 12, 2021

运行python pixiv_auth.py login出现问题,说我没有将chromedriver加到path里,但是我加了,并且自己写了个t.py,也可以正常打开百度(头痛)

# t.py

from selenium import webdriver
import time
driver = webdriver.Chrome()
driver.get('http://www.baidu.com')
time.sleep(5)
driver.quit()
Administrator@172_17_0_14 MINGW64 ~/Desktop/hoshino/HoshinoBot/hoshino/modules/LocalSetu (master)
$ python pixiv_auth.py login
Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] 系统找不到指定的文件。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "pixiv_auth.py", line 157, in <module>
    main()
  File "pixiv_auth.py", line 153, in main
    args.func(args)
  File "pixiv_auth.py", line 148, in <lambda>
    login_parser.set_defaults(func=lambda _: login())
  File "pixiv_auth.py", line 68, in login
    driver = webdriver.Chrome("./chromedriver", desired_capabilities=caps)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
    self.service.start()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

@smallsay

This comment has been minimized.

Copy link

@smallsay smallsay commented Sep 12, 2021

$ pip install chromedriver_binary==`google-chrome --version | sed "s/.*e //"`
Administrator@172_17_0_14 MINGW64 ~/Desktop/hoshino/HoshinoBot/hoshino/modules/LocalSetu (master)
$ pip install chromedriver_binary==`google-chrome --version | sed "s/.*e //"`
bash: google-chrome: command not found
ERROR: Could not find a version that satisfies the requirement chromedriver_binary==
ERROR: No matching distribution found for chromedriver_binary==
@smallsay

This comment has been minimized.

Copy link

@smallsay smallsay commented Sep 12, 2021

$ which google-chrome || sudo pacman -Syu google-chrome
$ pip install chromedriver_binary==`google-chrome --version | sed "s/.*e //"`
Administrator@172_17_0_14 MINGW64 ~/Desktop/hoshino/HoshinoBot/hoshino/modules/LocalSetu (master)
$ which google-chrome || sudo pacman -Syu google-chrome
which: no google-chrome in (/c/Users/Administrator/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/Administrator/bin:/c/Program Files (x86)/Common Files/Oracle/Java/javapath:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Program Files/QCloud/Monitor/Barad:/cmd:/c/Program Files (x86)/Windows Kits/8.1/Windows Performance Toolkit:/c/ffmpeg/bin:/c/Program Files/Google/Chrome/Application:/c/Users/Administrator/AppData/Local/Programs/Python/Python38/Scripts:/c/Users/Administrator/AppData/Local/Programs/Python/Python38:/c/Users/Administrator/AppData/Local/Microsoft/WindowsApps:/c/Program Files/Google/Chrome/Application:/usr/bin/vendor_perl:/usr/bin/core_perl)
bash: sudo: command not found

Administrator@172_17_0_14 MINGW64 ~/Desktop/hoshino/HoshinoBot/hoshino/modules/LocalSetu (master)
$ pip install chromedriver_binary==`google-chrome --version | sed "s/.*e //"`
bash: google-chrome: command not found
ERROR: Could not find a version that satisfies the requirement chromedriver_binary==
ERROR: No matching distribution found for chromedriver_binary==
WARNING: You are using pip version 21.0.1; however, version 21.2.4 is available.
You should consider upgrading via the 'c:\users\administrator\appdata\local\programs\python\python38\python.exe -m pip install --upgrade pip' command.
@smallsay

This comment has been minimized.

Copy link

@smallsay smallsay commented Sep 12, 2021

$ which google-chrome || pacman -Syu google-chrome
$ pip install selenium chromedriver_binary==`google-chrome --version | sed "s/.*e //"`

dalao如果有事要忙的话这个可以先放放的,我不着急0.0

Administrator@172_17_0_14 MINGW64 ~/Desktop/hoshino/HoshinoBot/hoshino/modules/LocalSetu (master)
$ which google-chrome || pacman -Syu google-chrome
which: no google-chrome in (/c/Users/Administrator/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/Administrator/bin:/c/Program Files (x86)/Common Files/Oracle/Java/javapath:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Program Files/QCloud/Monitor/Barad:/cmd:/c/Program Files (x86)/Windows Kits/8.1/Windows Performance Toolkit:/c/ffmpeg/bin:/c/Program Files/Google/Chrome/Application:/c/Users/Administrator/AppData/Local/Programs/Python/Python38/Scripts:/c/Users/Administrator/AppData/Local/Programs/Python/Python38:/c/Users/Administrator/AppData/Local/Microsoft/WindowsApps:/c/Program Files/Google/Chrome/Application:/usr/bin/vendor_perl:/usr/bin/core_perl)
bash: pacman: command not found

Administrator@172_17_0_14 MINGW64 ~/Desktop/hoshino/HoshinoBot/hoshino/modules/LocalSetu (master)
$ pip install selenium chromedriver_binary==`google-chrome --version | sed "s/.*e //"`
bash: google-chrome: command not found
Requirement already satisfied: selenium in c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages (3.141.0)
ERROR: Could not find a version that satisfies the requirement chromedriver_binary==
ERROR: No matching distribution found for chromedriver_binary==
WARNING: You are using pip version 21.0.1; however, version 21.2.4 is available.
You should consider upgrading via the 'c:\users\administrator\appdata\local\programs\python\python38\python.exe -m pip install --upgrade pip' command.
@eggplants

This comment has been minimized.

Copy link

@eggplants eggplants commented Sep 12, 2021

I'm not familiar with your terminal (MINGW64?) and its package installer&manager.
You should install google-chrome with it.
Also you have to install selenium and chromedriver_binary from PyPI.
chromedriver_binary's version maybe accord google-chrome.

@smallsay

This comment has been minimized.

Copy link

@smallsay smallsay commented Sep 12, 2021

I'm not familiar with your terminal (MINGW64?) and its package installer&manager.
You should install google-chrome with it.
Also you have to install selenium and chromedriver_binary from PyPI.
chromedriver_binary's version maybe accord google-chrome.

Ths,i will try it . and my computer is windows 10 ( git bash )

I've installed Chrome and selenium

After install selenium and update chromedriver version , i run a test case, its successful open chrom

But when i want to run " python pixiv_auth.py login " it failed

# t.py

from selenium import webdriver
import time
driver = webdriver.Chrome()
driver.get('http://www.baidu.com')
time.sleep(5)
driver.quit()
@eggplants

This comment has been minimized.

Copy link

@eggplants eggplants commented Sep 12, 2021

Ah, I didn't understand. try to fix File "pixiv_auth.py", line 68, in login:

- driver = webdriver.Chrome("./chromedriver", desired_capabilities=caps)
+ driver = webdriver.Chrome(desired_capabilities=caps)
@smallsay

This comment has been minimized.

Copy link

@smallsay smallsay commented Sep 12, 2021

Ah, I didn't understand. try to fix File "pixiv_auth.py", line 68, in login:

- driver = webdriver.Chrome("./chromedriver", desired_capabilities=caps)
+ driver = webdriver.Chrome(desired_capabilities=caps)

It work , Ths .
And It's my fault , I should use English

@eggplants

This comment has been minimized.

Copy link

@eggplants eggplants commented Sep 12, 2021

I'm glad I could help. 👍
No problem, it is my fault for not understanding the Chinese language and the log well.

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