我無法找到瀏覽器解決方案。如果您對非瀏覽器解決方案還滿意,那麼在重定向之後有一個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)
只要使用fiddler2就足夠了嗎? –
@JanDvorak你能詳細解釋一下嗎? –