Open url from csv

How to call / refer url (website name) from csv ?

Tried
Command: Open
Target:
Value: ${!COL1}

Tried the target as blank and browser but no luck.

${!COL1} should be in the 2nd column (called “Target”), see OPEN.

And before this, use csvRead to read the data.

Here is a macro that does this (plus takes screenshot of the loaded page):

{
  "CreationDate": "2018-6-27",
  "Commands": [
    {
      "Command": "csvRead",
      "Target": "url.csv",
      "Value": ""
    },
    {
      "Command": "open",
      "Target": "${!col1}",
      "Value": ""
    },
    {
      "Command": "comment",
      "Target": "Remove non alphanumeric chars from URL, so we can use it as screenshot file name",
      "Value": ""
    },
    {
      "Command": "storeEval",
      "Target": "var string = \"${!col1}\"; var stripped = string.replace(/[^A-Za-z0-9]/g, ''); stripped;",
      "Value": "alphanumericonly"
    },
    {
      "Command": "captureScreenshot",
      "Target": "screenshot_for_${alphanumericonly}",
      "Value": ""
    }
  ]
}

The CSV file is just a list of URLs e. g.

https://a9t9.com
https://ocr.space
https://forum.a9t9.com

:exclamation: Run the macro in a loop to read all URLs from the CSV.

Thanks for quick response but it’s not working.
Showing as “status] Playing macro test”.

Earlier it was opening “chrome-extension://gcbalfbdmfieckjlnblleoemohcganoc/$%7B!COL1%7D”
and log shows below:
[error]
until: ipc of tab to play expired!

If I open a web page and later use the above mentioned code, it’s working.

{
“CreationDate”: “2018-6-28”,
“Commands”: [
{
“Command”: “open”,
“Target”: “Nya MSN Sverige | Nyheter, Nöje, Hotmail, Outlook och Vädret”,
“Value”: “”
},
{
“Command”: “csvRead”,
“Target”: “urls.csv”,
“Value”: “”
},
{
“Command”: “open”,
“Target”: “${!COL1}”,
“Value”: “”
}
]
}

Looks like a defect !!!
Expecting web page to continue the steps.

Kantu (like any Chrome extension) can only work on pages that have “something” loaded using the http://, https:// or file:// protocol.

So if you start the macro while (for example) chrome://settings/clearBrowserData or the Chrome start page is open, it can not connect to the browser tab. That is why adding a Open at the very top solves it.

That said, csvRead (unlike, say, Click or Type) should not require any web page (tab) connection, so indeed, it looks there is a bug here. I added this to our todo list, thanks for reporting it!

1 Like

Thanks for fixing the bug, it’s working fine now.

This defect looks like still existing when we leave the page for long time.
It’s working fine after closing chrome and reopening!!!

IPC issues are fixed with Kantu V3.1.6 :grinning:

I updated the above example to use the new commands such as csvReadArray, executeScript_Sandbox and forEach:

    {
      "Name": "url from csv",
      "CreationDate": "2021-7-19",
      "Commands": [
        {
          "Command": "csvReadArray",
          "Target": "url.csv",
          "Value": "myCSV",
          "Description": ""
        },
        {
          "Command": "echo",
          "Target": "Number of rows = ${!CsvReadMaxRow}",
          "Value": "green",
          "Description": ""
        },
        {
          "Command": "executeScript_Sandbox",
          "Target": "return ${mycsv[0]}.length;",
          "Value": "col",
          "Description": ""
        },
        {
          "Command": "echo",
          "Target": "Number of columns = ${col}",
          "Value": "pink",
          "Description": ""
        },
        {
          "Command": "comment",
          "Target": "loop over all CSV values in the array",
          "Value": "",
          "Description": ""
        },
        {
          "Command": "forEach",
          "Target": "myCSV",
          "Value": "row",
          "Description": "With each loop, we copy a new arraw ROW into the ${row[0] variable"
        },
        {
          "Command": "echo",
          "Target": "url is ${row[0]}",
          "Value": "brown",
          "Description": ""
        },
        {
          "Command": "open",
          "Target": "${row[0]}",
          "Value": "",
          "Description": ""
        },
        {
          "Command": "executeScript_Sandbox",
          "Target": "var string = ${row[0]}; var stripped = string.replace(/[^A-Za-z0-9]/g, ''); return stripped;",
          "Value": "alphanumericonly",
          "Description": "Remove non alphanumeric chars from URL, so we can use it as screenshot file name"
        },
        {
          "Command": "captureScreenshot",
          "Target": "screenshot_for_${alphanumericonly}",
          "Value": "",
          "Description": ""
        },
        {
          "Command": "end",
          "Target": "",
          "Value": "",
          "Description": ""
        }
      ]
    }