@summary: 可快速将浏览器上的header转为json格式 --------- @param text: --------- @result:
(text)
| 2304 | |
| 2305 | |
| 2306 | def quick_to_json(text): |
| 2307 | """ |
| 2308 | @summary: 可快速将浏览器上的header转为json格式 |
| 2309 | --------- |
| 2310 | @param text: |
| 2311 | --------- |
| 2312 | @result: |
| 2313 | """ |
| 2314 | |
| 2315 | contents = text.split("\n") |
| 2316 | json = {} |
| 2317 | for content in contents: |
| 2318 | if content == "\n": |
| 2319 | continue |
| 2320 | |
| 2321 | content = content.strip() |
| 2322 | regex = ["(:?.*?):(.*)", "(.*?):? +(.*)", "([^:]*)"] |
| 2323 | |
| 2324 | result = get_info(content, regex) |
| 2325 | result = result[0] if isinstance(result[0], tuple) else result |
| 2326 | try: |
| 2327 | json[result[0]] = eval(result[1].strip()) |
| 2328 | except: |
| 2329 | json[result[0]] = result[1].strip() |
| 2330 | |
| 2331 | return json |
| 2332 | |
| 2333 | |
| 2334 | ############################## |
nothing calls this directly
no test coverage detected