如何使用CSV文件(BAT文件)中的URL列表正确进行循环 [英] How to properly make a loop with a list of URLS from a CSV file (BAT file)

查看:130
本文介绍了如何使用CSV文件(BAT文件)中的URL列表正确进行循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将URL列表从CSV文件加载到BAT文件,并使其转到这些URL中的每个URL,然后将其关闭并转到下一个URL.

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.

我知道这是可能的,但是我发现的其他线程太复杂了,我不知道该在哪里保存CSV文件.

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

我需要一个可以访问500个URL的代码.您能否显示一个示例,说明我如何进入代码中的每个步骤? (或如何执行循环,但我需要循环包含5秒的timeout,然后在每个循环中包含taskkill.

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.

推荐答案

假设您的CSV看起来像这样(每行只有一个URL,没有其他内容):

Assuming your CSV looks like this (just one URL per line, nothing else):

www.google.com
www.facebook.com
www.stackoverflow.com

然后,您只需要一个简单的for /f循环:

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
)

这篇关于如何使用CSV文件(BAT文件)中的URL列表正确进行循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆