How to properly make a loop with a list of URLS from a CSV file (BAT file)

坚强是说给别人听的谎言 提交于 2020-01-17 15:09:53

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!