You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
在把本库用于其他地方时,由于香港IP无法使用yandex搜图,但是我不知情,只在本地机上测试发现可用跑通,在香港小机上时,发生了报错只提示“ the JSON object must be str, bytes or bytearray, not NoneType”,令人一头雾水,然后查看详细报错,内容是:
File "d:\Programs\PicImageSearch-main\PicImageSearch-main\demo\code\yandex.py", line 40, in test_async
resp = await yandex.search(url=url)
│ │ └ 'https://raw.githubusercontent.com/kitUIN/PicImageSearch/main/demo/images/test06.jpg'
│ └ <function Yandex.search at 0x0000013A780CAE60>
└ <PicImageSearch.engines.yandex.Yandex object at 0x0000013A7819B250>
File "D:\Programs\PicImageSearch-main.venv\lib\site-packages\PicImageSearch\engines\yandex.py", line 83, in search
return YandexResponse(resp.text, resp.url)
│ │ │ │ └ _tuplegetter(1, 'Alias for field number 1')
│ │ │ └ RESP(text='\n\n\n \n <meta name="viewport" content="width=de...
│ │ └ _tuplegetter(0, 'Alias for field number 0')
│ └ RESP(text='\n\n\n \n <meta name="viewport" content="width=de...
└ <class 'PicImageSearch.model.yandex.YandexResponse'>
File "D:\Programs\PicImageSearch-main.venv\lib\site-packages\PicImageSearch\model\base.py", line 72, in init
self._parse_response(resp_data, resp_url=resp_url, **kwargs)
│ │ │ │ └ {}
│ │ │ └ 'https://yandex.com/images/search?rpt=imageview&cbir_page=sites&url=https%3A%2F%2Fraw.githubusercontent.com%2FkitUIN%2FPicIma...
│ │ └ '\n\n\n \n <meta name="viewport" content="width=device-width...
│ └ <function YandexResponse._parse_response at 0x0000013A77EADF30>
└ <PicImageSearch.model.yandex.YandexResponse object at 0x0000013A7819B220>
File "D:\Programs\PicImageSearch-main.venv\lib\site-packages\PicImageSearch\model\yandex.py", line 97, in _parse_response
data_json = json_loads(data_div.attr("data-state"))
│ │ └ <pyquery.pyquery.FlexibleElement object at 0x0000013A77E20310>
│ └ []
└ <function loads at 0x0000013A776D9EA0>
File "C:\Users\13079\AppData\Local\Programs\Python\Python310\lib\json_init_.py", line 339, in loads
raise TypeError(f'the JSON object must be str, bytes or bytearray, '
哎呀Yandex太坏了,面前我没有很多IP,我的使用情况是这样的:两个HK机房IP访问https://yandex.com/images/均返回The service is under construction.We will be back soon.页面,其余一个法国和一个美国机房IP均能正常访问。
对于 https://yandex.ru/images/ 或 https://ya.ru/images/ 所有IP都能正常访问。。。
然后看到好像和yandex设置里的位置有关,我在香港IP时位置默认是香港,然后把位置改成其他地方,https://yandex.com/images/就又可以正常访问了,改回去则回到原来问题。就很迷惑,所以感觉添加详细报错确实有必要,谢谢作者的工作。
在把本库用于其他地方时,由于香港IP无法使用yandex搜图,但是我不知情,只在本地机上测试发现可用跑通,在香港小机上时,发生了报错只提示“ the JSON object must be str, bytes or bytearray, not NoneType”,令人一头雾水,然后查看详细报错,内容是:
依旧没有直接指出问题是因为返回的页面是无效页面,因为我写的代码涉及到一些转换,这里又提示TypeError,我在犯蠢以为是我写的代码导致输入或者解析出问题啥的一直困扰我很久,建议作者们添加更详细的报错,如这样的情况希望能直接返回“没有在页面上找到相关元素”之类的信息,还有就是在yandex示例代码界面提醒一下如香港ip根本就没有搜图这个网页这样的信息,能帮助更好定位问题。
The text was updated successfully, but these errors were encountered: