miumida / naver_weather

Naver Weather Sensor for Home Assistant #HA
31 stars 31 forks source link

Referer 추가 #17

Closed yms2772 closed 1 year ago

yms2772 commented 1 year ago

403 오류로 인해 날씨를 못가져와서 Referer 헤더 추가

오류내용:

2023-08-11 14:03:20.527 ERROR (MainThread) [custom_components.naver_weather.api_nweather] Failed to update NWeather API status Error: 403, message='Forbidden', url=URL('https://search.naver.com/search.naver?query=%EC%96%B4%EC%96%91%EB%8F%99+%EB%82%A0%EC%94%A8')
2023-08-11 14:03:20.529 ERROR (MainThread) [homeassistant.components.weather] Error adding entities for domain weather with platform naver_weather
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 510, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 750, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1003, in add_to_platform_finish
    await self.async_added_to_hass()
  File "/config/custom_components/naver_weather/nweather_device.py", line 69, in async_added_to_hass
    await self.api.update()
  File "/config/custom_components/naver_weather/api_nweather.py", line 207, in update
    response.raise_for_status()
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1005, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 403, message='Forbidden', url=URL('https://search.naver.com/search.naver?query=%EC%96%B4%EC%96%91%EB%8F%99+%EB%82%A0%EC%94%A8')
2023-08-11 14:03:20.536 ERROR (MainThread) [homeassistant.components.weather] Error while setting up naver_weather platform for weather
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 370, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 510, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 750, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1003, in add_to_platform_finish
    await self.async_added_to_hass()
  File "/config/custom_components/naver_weather/nweather_device.py", line 69, in async_added_to_hass
    await self.api.update()
  File "/config/custom_components/naver_weather/api_nweather.py", line 207, in update
    response.raise_for_status()
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1005, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 403, message='Forbidden', url=URL('https://search.naver.com/search.naver?query=%EC%96%B4%EC%96%91%EB%8F%99+%EB%82%A0%EC%94%A8')
miumida commented 1 year ago

Referer 추가하니 잘 되네요! PR 감사합니다:-)