Last active
January 6, 2018 11:40
-
-
Save leavyli/78a74ed0cd9dbf1e82fe3ffc881a2d58 to your computer and use it in GitHub Desktop.
python:web:headers:read from file:从文件读取请求头,多用在调试爬虫的时候,浏览器的请求头直接复制到文件读出来。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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