简体   繁体   English

Chrome开发者工具找不到HttpRequest

[英]Chrome developer tools cannot find HttpRequest

In Python, I'm using the requests library to POST an HTTPRequest to a URL. 在Python中,我正在使用requests库将HTTPRequest张贴到URL。 When I click this button however, it looks like nothing happens when following Chrome Developer Tools. 但是,当我单击此按钮时,遵循Chrome开发人员工具似乎没有任何反应。 No XHR requests, nothing is POSTed. 没有XHR请求,什么都没有发布。

When I click the button, a new window is opened, then immediately redirected to another page. 当我单击按钮时,将打开一个新窗口,然后立即重定向到另一个页面。 I'd like requests to POST a payload, then store the returned page after the redirect. 我想requests POST负载,然后在重定向后存储返回的页面。

Here's the button in the HTML: 这是HTML中的按钮:

<button type="button" id="form_submit" class="querysubmit" name="querysubmit" onclick="if (document.regform.onsubmit()) {$j('#queryform').submit();setTimeout('document.getElementById(\'form_submit\').disabled=false;document.getElementById(\'form_submit_image\').src=\'/img/btn_submitquery.gif\';',10000);this.disabled=true;document.getElementById('form_submit_image').src='/img/btn_querysubmitted.gif';}">
                     <img id="form_submit_image" src="/img/btn_submitquery.gif" alt="Submit Query">
                </button>

I'm trying to find the POST HTTPRequest so that I can add a payload to the request. 我正在尝试查找POST HTTPRequest,以便可以将有效负载添加到请求中。

new_page = session.post(QUERY_URL, data=payload_dict)

Does anyone know why when I hit the "Submit" button, nothing occurs in Chrome Developer tools yet a new page opens that processes the request? 有谁知道为什么当我点击“提交”按钮时,Chrome Developer工具中什么都没有发生,而是打开了一个处理请求的新页面?

You need to enable the "Preserve Log" option in the Network Panel. 您需要在“网络面板”中启用“保留日志”选项。 This will save the primary request information (but not the raw data!) for requests on page movement. 这将保存页面移动请求的主要请求信息(但不保存原始数据!)。

Your issue stems from the "immediately redirected to another page". 您的问题源于“立即重定向到另一个页面”。 When page movement occurs, DevTools dumps everything it can to conserve memory. 页面移动时,DevTools会转储所有内容以节省内存。 You would be better off using AJAX to submit the request and handle any response, that way no page redirect occurs. 使用AJAX提交请求并处理任何响应会更好,这样就不会发生页面重定向。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM