问题
I need to load a list of URLs from a CSV file to a BAT file and make it go to each one of those URLs, then close it and go to the next one.
I know it is possible, but the other threads I found are too complicated and I don't know where I need to save the CSV file.
This is the code I've already written:
start chrome https://www.google.co.in/
timeout 5
taskkill /f /im chrome.exe
I need a code that goes to 500 URLs. Can you show an example of how I go to each one of those in the code? (or how I do a loop but I need the loop to include timeout
of 5 seconds, then taskkill
on every single loop.
回答1:
Assuming your CSV
looks like this (just one URL per line, nothing else):
www.google.com
www.facebook.com
www.stackoverflow.com
Then you just need a simple for /f
loop:
@echo off
for /f "delims=" %%a in (list.csv) do (
start chrome "https:\\%%a"
timeout 5
taskkill /f /im chrome.exe
)
来源:https://stackoverflow.com/questions/58231392/how-to-properly-make-a-loop-with-a-list-of-urls-from-a-csv-file-bat-file