- 1 year ago
How to filter ChromeDevTools cURL correctly for Windows CMD?
To filter and capture cURL requests from Chrome DevTools in the Windows Command Prompt (CMD), you can use the findstr
command to filter the output. Here's an example:
Open the Windows Command Prompt (CMD).
Launch Google Chrome with remote debugging enabled by running the following command:
bash"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222
This starts Chrome with the remote debugging port set to 9222. You may need to adjust the path to the Chrome executable if it is installed in a different location on your system.
Open a new tab in Chrome and navigate to
chrome://inspect
. Under the "Remote Target" section, click the "Open dedicated DevTools for Node" link. This opens the DevTools window.In the DevTools window, perform the actions that trigger the cURL requests you want to capture.
In the Windows Command Prompt, run the following command to retrieve the cURL requests from the DevTools log:
bashcurl -s http://localhost:9222/json/list | findstr /C:"\"url\"" | findstr /R /C:"\"url\"\:\"http:\/\/(.*?)\""
This command retrieves the JSON data from the Chrome DevTools endpoint (
http://localhost:9222/json/list
), filters the lines containing"url"
, and extracts the lines that match the pattern"url":"http://..."
.Note that you need to have
curl
installed and added to the system's PATH environment variable for the above command to work. Adjust the path tocurl
if needed.The output will display the cURL requests captured from the Chrome DevTools log. You can copy and modify these cURL commands as needed.
By using the findstr
command to filter the output, you can extract and capture the relevant cURL requests from the Chrome DevTools log in the Windows Command Prompt.