GithubHelp home page GithubHelp logo

login操作异常 about pixivpy-async HOT 12 CLOSED

mikubill avatar mikubill commented on August 11, 2024
login操作异常

from pixivpy-async.

Comments (12)

Mikubill avatar Mikubill commented on August 11, 2024

这行表明程序正在自动重试。只要没有抛出错误就是正常运行完成了

from pixivpy-async.

yooziki avatar yooziki commented on August 11, 2024

不好意思,我这里遗漏了尝试十次后抛出的错误信息,我用....对我的文件路径做了部分替换

...
Exception during <function Net.auth at 0x000001741D01CE58> execution. 11 of 10 retries attempted
Traceback (most recent call last):
  File "....\CES\lib\site-packages\pixivpy_async\retry.py", line 28, in inner
    result = await func(*args, **kwargs)
  File "....\CES\lib\site-packages\pixivpy_async\net.py", line 37, in auth
    async with session.post(_url, headers=_headers, data=_data, **self.requests_kwargs) as response:
  File "....\CES\lib\site-packages\aiohttp\client.py", line 1012, in __aenter__
    self._resp = await self._coro
  File "....\CES\lib\site-packages\aiohttp\client.py", line 582, in _request
    break
  File "....\CES\lib\site-packages\aiohttp\helpers.py", line 596, in __exit__
    raise asyncio.TimeoutError from None
concurrent.futures._base.TimeoutError
Traceback (most recent call last):
  File "....\CES\lib\site-packages\pixivpy_async\retry.py", line 28, in inner
    result = await func(*args, **kwargs)
  File "....\CES\lib\site-packages\pixivpy_async\net.py", line 37, in auth
    async with session.post(_url, headers=_headers, data=_data, **self.requests_kwargs) as response:
  File "....\CES\lib\site-packages\aiohttp\client.py", line 1012, in __aenter__
    self._resp = await self._coro
  File "....\CES\lib\site-packages\aiohttp\client.py", line 582, in _request
    break
  File "....\CES\lib\site-packages\aiohttp\helpers.py", line 596, in __exit__
    raise asyncio.TimeoutError from None
concurrent.futures._base.TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "..../test.py", line 20, in <module>
    main()
  File "..../test.py", line 18, in main
    loop.run_until_complete(_main(AppPixivAPI()))
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\asyncio\base_events.py", line 587, in run_until_complete
    return future.result()
  File "..../test.py", line 13, in _main
    await papi.login(_USERNAME, _PASSWORD)
  File "....\CES\lib\site-packages\pixivpy_async\bapi.py", line 114, in login
    return await self.auth_req(url, headers, data)
  File "....\CES\lib\site-packages\pixivpy_async\bapi.py", line 117, in auth_req
    r, status, code = await self.auth(url, headers, data)
  File "....\CES\lib\site-packages\pixivpy_async\retry.py", line 37, in inner
    raise RetryExhaustedError(func.__qualname__, args, kwargs) from err
pixivpy_async.error.RetryExhaustedError: (<pixivpy_async.aapi.AppPixivAPI object at 0x000001741CF4FB88>, 'https://oauth.secure.pixiv.net/auth/token', {'User-Agent': 'PixivAndroidApp/5.0.64 (Android 6.0)', 'X-Client-Time': '2020-09-03T05:36:18+00:00', 'X-Client-Hash': 'd9dd538d508bc9774628ef511654eed6'}, {'get_secure_url': 1, 'client_id': 'MOBrBDS8blbauoSck0ZfDbtuzpyT', 'client_secret': 'lsACyCD94FhDUtGTXi3QzcFE2uU1hqtDaKeqrdwj', 'grant_type': 'password', 'username': '<name>', 'password': '<pswd>'}), {}

from pixivpy-async.

Mikubill avatar Mikubill commented on August 11, 2024

超时错误一般是网络问题。可以把使用pixivpy登陆时的程序代码发一下嘛?

from pixivpy-async.

yooziki avatar yooziki commented on August 11, 2024

这是我写的最简短的登录程序,它能够正常退出,运行后能够收到P站发来的登录邮件

from pixivpy3 import AppPixivAPI
_USERNAME = <str>
_PASSWORD = <str>

def main():
    api = AppPixivAPI()
    api.login(_USERNAME,_PASSWORD)

if __name__ == '__main__':
    main()

from pixivpy-async.

Mikubill avatar Mikubill commented on August 11, 2024

请问是否有使用代理程序或者是设置了系统代理设置呢..?
刚刚测试了一下,pixivpy3使用的requests是默认使用env中的代理设置的,但pixivpy_async使用的aiohttp默认是不使用代理设置,需要手动开启。可能是这个造成的问题

from pixivpy-async.

yooziki avatar yooziki commented on August 11, 2024

我是使用了代理程序,可能这就是问题所在..
不过我没有找到手动设置的方法,可以更详细的指明一下吗?谢谢
也许我应该更换成路由代理会更加方便?

from pixivpy-async.

Mikubill avatar Mikubill commented on August 11, 2024

做了一些修改;使用最新版本(可以用 pip install git+https://github.com/Mikubill/pixivpy-async 安装或者等待晚些发到pypi上的更新,参照下面的方法请求就好了:

from pixivpy_async.sync import AppPixivAPI 

_USERNAME = <str>
_PASSWORD = <str>

def login():
    api = AppPixivAPI(env=True)
    api.login(_USERNAME, _PASSWORD)

from pixivpy-async.

yooziki avatar yooziki commented on August 11, 2024

谢谢!不过直接使用env=True方式设置没有包含使用https代理的情况,在使用https代理的时候会发生
HTTPS proxies https://127.0.0.1:2089 are not supported, ignoring
也许可以使用如下转换

def get_local_proxy():
    from urllib.request import getproxies
    proxy = getproxies()['http']
    return proxy

可是我不知道应该放到哪个地方合适,我对aiohttp模块是陌生的

from pixivpy-async.

Mikubill avatar Mikubill commented on August 11, 2024

这个只是获得http代理的路径,但是没有实现代理请求的内容;aiohttp我看了一下目前只支持http/socks代理,只要设置了其中一个应该就可以使用。如有有什么好的代理解决方案到时候再加上)

from pixivpy-async.

yooziki avatar yooziki commented on August 11, 2024

谢谢!我现在开始考虑如何使用http代理而不是https了

from pixivpy-async.

LuneZ99 avatar LuneZ99 commented on August 11, 2024

遇到了一系列同样的问题,发现在使用代理程序时,代理程序一般会同时开启https和socks5代理,此时直接设置env=True程序自动检测到的是https代理,导致HTTPS proxies <url> are not supported, ignoring的问题。
而在每次发起 get 请求时手动指定 SOCKS5 代理,则会出现 aiohttp 仅支持HTTP的报错。
于是找了相关的库,尝试支持了一下 SOCKS5,以及支持在初始化 Client 的时候手动指定代理链接来避免自动检测的失误,本地测试了下是可行的。

from pixivpy-async.

LuneZ99 avatar LuneZ99 commented on August 11, 2024

#14

from pixivpy-async.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.