Closed pmj110119 closed 3 years ago
是用的ByPass还是挂的代理?是无论什么图片都必然连接超时吗?
感谢回复。之前是bypass+代理 现在把代理关了 ` json_result = api.illust_ranking('day', date=(datetime.now() - timedelta(days=5)).strftime('%Y-%m-%d'))
print("Printing image titles and tags with English tag translations present when available")
for illust in json_result.illusts[:3]: print("Illustration: \"" + str(illust.title) + "\"\nTags: " + str(illust.tags) + "\n") api.download(illust.image_urls.large)` 在调用download时报错
`Illustration: "セタンタ" Tags: [{'name': 'Fate/GrandOrder', 'translated_name': 'Fate/Grand Order'}, {'name': 'FGO', 'translated_name': 'Fate/Grand Order'}, {'name': 'FGOアーケード', 'translated_name': None}, {'name': 'セタンタ(Fate)', 'translated_name': None}, {'name': '本家', 'translated_name': 'created by the original author'}, {'name': 'Fate/GO20000users入り', 'translated_name': 'Fate/Grand Order 20000+ bookmarks'}]
Traceback (most recent call last): File "C:\ProgramData\Anaconda3\envs\qq\lib\site-packages\urllib3\connection.py", line 170, in _new_conn (self._dns_host, self.port), self.timeout, **extra_kw File "C:\ProgramData\Anaconda3\envs\qq\lib\site-packages\urllib3\util\connection.py", line 96, in create_connection raise err File "C:\ProgramData\Anaconda3\envs\qq\lib\site-packages\urllib3\util\connection.py", line 86, in create_connection sock.connect(sa) ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。`
首先,ByPass方法不能作用于download,download是直接访问P站的CDN url: https://github.com/upbit/pixivpy/blob/master/pixivpy3/api.py#L134
挂代理应该是有效的,可以把作品的URL打印下,用浏览器+Referer: https://app-api.pixiv.net/
请求看看(代理下)
如果这样也无法访问,基本就可以说明代理到图片的CDN不通
另外,如果浏览器可以但API还是不可访问,这个 Referer 可能要调整下:
api.download(..., referer="新referer")
api.illust_ranking()正常,但加了api.download()就连接超时了。请问这可能是什么原因呢?
Traceback (most recent call last): File "C:\ProgramData\Anaconda3\envs\qq\lib\site-packages\urllib3\connection.py", line 170, in _new_conn (self._dns_host, self.port), self.timeout, **extra_kw File "C:\ProgramData\Anaconda3\envs\qq\lib\site-packages\urllib3\util\connection.py", line 96, in create_connection raise err File "C:\ProgramData\Anaconda3\envs\qq\lib\site-packages\urllib3\util\connection.py", line 86, in create_connection sock.connect(sa) TimeoutError: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。