Skip to content

Instantly share code, notes, and snippets.

@leavyli
Last active January 6, 2018 11:40
Show Gist options
  • Save leavyli/78a74ed0cd9dbf1e82fe3ffc881a2d58 to your computer and use it in GitHub Desktop.
Save leavyli/78a74ed0cd9dbf1e82fe3ffc881a2d58 to your computer and use it in GitHub Desktop.
python:web:headers:read from file:从文件读取请求头,多用在调试爬虫的时候,浏览器的请求头直接复制到文件读出来。
headers = {}
with open(r"e:/test/header") as f:
s = f.read()
for i in s.split("\n"):
k = i.split(":")[0]
v = i.split(":")[1]
headers[k.strip()] = v.strip()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment