【问题标题】:Cannot retreive CSP header with python无法使用 python 检索 CSP 标头
【发布时间】:2018-03-06 10:35:46
【问题描述】:

我想从某个站点检索所有标题,在本例中为“https://www.facebook.com”,如下所示:

import urllib2
enter code here`req = urllib2.Request('https://www.facebook.com/')
res = urllib2.urlopen(req)
print res.info()
res.close();

导致此响应:

X-XSS-Protection: 0
Pragma: no-cache
Cache-Control: private, no-cache, no-store, must-revalidate
X-Frame-Options: DENY
Strict-Transport-Security: max-age=15552000; preload
X-Content-Type-Options: nosniff
Expires: Sat, 01 Jan 2000 00:00:00 GMT
Set-Cookie: sb=1GyeWkJzGbmX-VUyBi26; expires=Thu, 05-Mar-2020 10:26:28 GMT; Max-Age=63071999; path=/; domain=.facebook.com; secure; httponly
Vary: Accept-Encoding
Content-Type: text/html; charset=UTF-8
X-FB-Debug: X9aSOOKs6/aER1yuY4iUUIZrj4yTKtKSUAZ/AFE37IieCe8O4MSsFc5xlQ0LoQyHnbrSL4DaYiTVUUkFZeDrsqqg==
Date: Tue, 06 Mar 2018 10:26:29 GMT
Connection: close

我可以检索除 Content-Security-Policy (csp) 之外的所有标头; 但每当我测试geekflare csp test 它成功地检索了包括 csp 在内的所有标头。

【问题讨论】:

    标签: python http header response content-security-policy


    【解决方案1】:

    好像我忘记在请求中设置用户代理了。

    【讨论】:

      猜你喜欢
      • 2019-02-27
      • 2018-11-28
      • 1970-01-01
      • 1970-01-01
      • 2018-12-30
      • 1970-01-01
      • 2013-05-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多