#问题:#raise InvalidSchema("No connection adapters were found for {!r}".format(url))
requests.exceptions.InvalidSchema: No connection adapters were found for
#代码:#
```python
import requests
from bs4 import BeautifulSoup
url =['https://mip.phb123.com/city/renkou/rk_{}.html'.format(str(i)) for i in range(1,6)]
headers = {"user-agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 Edg/108.0.1462.46"}
response = requests.get(url,headers=headers)
print(response.text)
listData = []
soup = BeautifulSoup(response.text,'html.parser')
tr = soup.find(attrs={'class':'rank-table'}).find_all('tr')
for j in tr[1:]:
td = j.find_all('td')
a = td[0].get_text().strip()
b = td[1].get_text().strip()
c = td[2].get_text().strip()
d = td[3].get_text().strip()
e = td[4].get_text().strip()
listData = ([a,b,c,d,e])
print('世界排名=%s' %a,'国家=%s' %b,'人口数量=%s' %c,'增长率=%s' %d,'人口密度=%s' %e)
#报错:#
```python
F:\Anaconda\python.exe "F:/数据采集/pycharm file/untitled/1/世界人口.py"
Traceback (most recent call last):
File "F:/数据采集/pycharm file/untitled/1/世界人口.py", line 8, in
response = requests.get(url,headers=headers)
File "F:\Anaconda\lib\site-packages\requests\api.py", line 76, in get
return request('get', url, params=params, **kwargs)
File "F:\Anaconda\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "F:\Anaconda\lib\site-packages\requests\sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "F:\Anaconda\lib\site-packages\requests\sessions.py", line 649, in send
adapter = self.get_adapter(url=request.url)
File "F:\Anaconda\lib\site-packages\requests\sessions.py", line 742, in get_adapter
raise InvalidSchema("No connection adapters were found for {!r}".format(url))
requests.exceptions.InvalidSchema: No connection adapters were found for "['https://mip.phb123.com/city/renkou/rk_1.html', 'https://mip.phb123.com/city/renkou/rk_2.html', 'https://mip.phb123.com/city/renkou/rk_3.html', 'https://mip.phb123.com/city/renkou/rk_4.html', 'https://mip.phb123.com/city/renkou/rk_5.html']"
Process finished with exit code 1