Mail.ruПочтаМой МирОдноклассникиВКонтактеИгрыЗнакомстваНовостиКалендарьОблакоЗаметкиВсе проекты

Requests python ошибка

Роман Бобровский Ученик (41), на голосовании 1 неделю назад
Ввел я значит код из тик тока, но у меня он не работает
вот код:
import requests


def get_weather(city):
url = f" https://wittr.in/{city}?lang=ru "
responce = requests.get(url)
if responce.status_code == 200:
return responce.text
else:
return "Ошибка при получении данных"


def main():
city = "Москва"
print(get_weather(city))


if __name__ == "__main__":
main()
и вот такая ошибка сказала мне Гуляй
raceback (most recent call last):
File "C:\Users\Роман\Desktop\Vkweather\.venv\Lib\site-packages\urllib3\connection.py", line 198, in _new_conn
sock = connection.create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Роман\Desktop\Vkweather\.venv\Lib\site-packages\urllib3\util\connection.py", line 60, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Роман\AppData\Local\Programs\Python\Python312\Lib\socket.py", line 963, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
socket.gaierror: [Errno 11001] getaddrinfo failed

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

Traceback (most recent call last):
File "C:\Users\Роман\Desktop\Vkweather\.venv\Lib\site-packages\urllib3\connectionpool.py", line 793, in urlopen
response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "C:\Users\Роман\Desktop\Vkweather\.venv\Lib\site-packages\urllib3\connectionpool.py", line 491, in _make_request
raise new_e
Голосование за лучший ответ
Похожие вопросы