停止在浏览器开发工具

问题描述:

我观察在Chrome浏览器开发工具系列的重定向,“网络”选项卡上的网络请求:停止在浏览器开发工具

enter image description here

我需要能够经过暂停重定向链请求已出现在“网络”中(以便我可以将其复制为cURL),但在执行之前。像“暂停任何网络活动”。我在Chrome开发工具,Firefox Web Developer,Firebug,Safari中搜索了这个功能 - 但无济于事。最接近的是萤火虫中的“暂停XHR”,但这些重定向不是XHR。

如果能够完成这项工作,我会接受非浏览器解决方案(脚本?),尽管我觉得这应该可以通过浏览器开发工具来实现。

我无法找到浏览器解决方案。如果您对非浏览器解决方案还满意,那么在重定向之后有一个python脚本(它也使用requests库),直到找到一些后缀并打印cURL的请求。

#!/usr/bin/env python 

import requests 
import sys 

def formatRequestAscURL(request): 
    command = "curl -X {method} -H {headers} -d '{data}' '{url}'" 
    method = request.method 
    url = request.url 
    data = request.body 
    headers = ["{0}: {1}".format(k, v) for k, v in request.headers.items()] 
    headers = " -H ".join(headers) 
    return command.format(method=method, headers=headers, data=data, url=url) 


def followUntilSuffix(startURL, suffix): 
    response = requests.get(startURL, allow_redirects=False) 
    session = requests.Session() 
    requests_iter = session.resolve_redirects(response, response.request) 

    for r in requests_iter: 
     if r.request.path_url.endswith(suffix): 
      print formatRequestAscURL(r.request) 
      return 

    print 'Required redirect isn\'t found' 


if len(sys.argv) < 3: 
    print 'This script requires two parameters:\n 1) start url \n 2) url suffix for stop criteria' 
    sys.exit() 

startURL = sys.argv[1] 
stopSuffix = sys.argv[2] 

followUntilSuffix(startURL, stopSuffix) 
+0

只要使用fiddler2就足够了吗? –

+0

@JanDvorak你能详细解释一下吗? –