学爬虫的第一个问题

孤者浪人 提交于 2020-01-28 12:13:36

requests遇到的错误

1,443错误 requests05


```python
port=443): Max retries exceeded with url: 
/sug (Caused by NewConnectionError
('<urllib3.connection.VerifiedHTTPSConnection object 
at 0x0000000003ABF518>: Failed to establish a new 
connection: [Errno 11004] getaddrinfo failed',))

Process finished with exit code 1

**解决方法:从百度找了,只需要安装几个requests依赖包就可以
pip install cryptography
pip install pyOpenSSL
pip install certifi** 
然后又报错

```python
 for item in json_data['data']:
TypeError: string indices must be integers

这个错误意思是字符串的下标一定要是整数
原因是未把字符串转换为json对象 转换即可

将字符串转化为json对象

json_data = json.loads(json_data)
运行成功
在这里插入图片描述

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!