DeprecationWarning: HTTPResponse.getheader() is deprecated and will be removed in urllib3 v2.1.0. Instead use HTTPResponse.headers.get() with Selenium

huangapple go评论65阅读模式
英文:

DeprecationWarning: HTTPResponse.getheader() is deprecated and will be removed in urllib3 v2.1.0. Instead use HTTPResponse.headers.get() with Selenium

问题

每次运行我的Selenium脚本时,都会显示一些警告。有人能解释一下这些警告的原因以及如何解决吗?

C:\Users54-Talha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\remote_connection.py:418: DeprecationWarning: HTTPResponse.getheader() is deprecated and will be removed in urllib3 v2.1.0. Instead use HTTPResponse.headers.get(name, default).
  if resp.getheader('Content-Type') is not None:
C:\Users54-Talha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\remote_connection.py:419: DeprecationWarning: HTTPResponse.getheader() is deprecated and will be removed in urllib3 v2.1.0. Instead use HTTPResponse.headers.get(name, default).
  content_type = resp.getheader('Content-Type').split(';')
英文:

Every time when i run my selenium script it shows some warnings. Can anyone explain me the reason of the warnings and how to solve it.

C:\Users54-Talha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\remote_connection.py:418: DeprecationWarning: HTTPResponse.getheader() is deprecated and will be removed in urllib3 v2.1.0. Instead use HTTPResponse.headers.get(name, default).
  if resp.getheader('Content-Type') is not None:
C:\Users54-Talha\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\remote_connection.py:419: DeprecationWarning: HTTPResponse.getheader() is deprecated and will be removed in urllib3 v2.1.0. Instead use HTTPResponse.headers.get(name, default).
  content_type = resp.getheader('Content-Type').split(';')

答案1

得分: 1

Selenium 需要 urllib3

getheader() 已被弃用,将在 urllib3 v2.1.0 中移除。相反,使用 Selenium 时,我们需要使用 HTTPResponse.headers.get(name, default)

详情

这个问题在DeprecationWarning: HTTPResponse.getheader() is deprecated and will be removed in urllib3 v2.1.0.中讨论,通过拉取请求Replace response.getheader() with response.headers.get()来解决,该请求用response.getheader()替换了response.headers.get(),这在 urllib3 1.26.13 中被弃用,这将在使用 selenium 4.6.1 及更高版本时防止许多弃用警告。

解决方案

升级到 Selenium 4.6.1 或更高版本。

英文:

Selenium requires urllib3

DeprecationWarning: HTTPResponse.getheader() is deprecated and will be removed in urllib3 v2.1.0. Instead use HTTPResponse.headers.get() with Selenium

getheader() is deprecated now and will be removed in urllib3 v2.1.0. Instead with Selenium we need to use HTTPResponse.headers.get(name, default).


Details

This issue was discussed in the thread DeprecationWarning: HTTPResponse.getheader() is deprecated and will be removed in urllib3 v2.1.0. and was addressed through pull request Replace response.getheader() with response.headers.get() which replaces response.getheader() with response.headers.get() deprecated in urllib3 1.26.13 which will prevent lots of deprecation warnings when using the selenium 4.6.1 and above.


Solution

Upgrade to Selenium 4.6.1 or above.

答案2

得分: -1

HTTPResponse.getheader() 已弃用,并将在 urllib3 v2.1.0 中移除。请改用 HTTPResponse.headers.get(name, default)

英文:

HTTPResponse.getheader() is deprecated and will be removed in urllib3 v2.1.0. Instead use HTTPResponse.headers.get(name, default)

huangapple
  • 本文由 发表于 2023年2月8日 15:23:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/75382508.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定