Read from CSV & Save it new CSV

dear sir,

I’ve a CSV which contains website URL,
I’m able to Read the File and Open the URL too

I just want 2 things more to be done

  1. Copy a Text from the Website Page
  2. Paste it in a New CSV file.

Can anybody give me the code to do this

It’s easier for you to read the instructions on how to select text, store it and put it in a variable because it can be long-winded to explain, but I’ll try.

Open the web-page.

Click: Add
In the Command dropdown, select: storeText
Next to Target, Click the button: Select
Place mouse on the text you wish to grab from the web-page
In Value, write: textValue (you can actually write any name here)

Scroll-up to the first line of your script (csvRead), and click the + button

In the Command dropdown, select: Store
In Target, write: output.csv
In Value, write: outputCsvFile

Scroll-down to the bottom of your script.

Click: Add
In the Command dropdown, select: Store
In Target, write: ${textValue}
In Value, write: !csvLine

Click: Add
In the Command dropdown, select: csvSave
In Target, write: ${outputCsvFile}
In Value, write: !csvLine

I did get disturbed writing the above but I hope it works. Good luck.

thanks a lot @TheWhippinpost, but for some weird reasons, i’m getting this error, though I’m sure it exists.

  • [info]Executing: | storeText | //*[@id=“app__container”]/main/div/div[2]/p | website |
  • [error]timeout reached when looking for element ‘//*[@id=“app__container”]/main/div/div[2]/p’

At the point in my instructions, where you select the text from the website page, instead of clicking Select, click Find

It should highlight the actual part of the page the script is looking for. Make sure it’s correct; if not, repeat the Select procedure, ensuring it’s the correct element.

thanks @TheWhippinpost, but it is not saving into the CSV file, is the order I’m doing it in correct, please can you check the below code

{
  "Name": "Ishan",
  "CreationDate": "2019-3-7",
  "Commands": [
    {
      "Command": "csvRead",
      "Target": "test2.csv",
      "Value": ""
    },
    {
      "Command": "store",
      "Target": "test.csv",
      "Value": "test"
    },
    {
      "Command": "open",
      "Target": "${!col2}",
      "Value": ""
    },
    {
      "Command": "storeText",
      "Target": "//*[@id=\"homepage\"]/header/div/div[2]/div/h4",
      "Value": "website"
    },
    {
      "Command": "store",
      "Target": "${website}",
      "Value": "!csvLine"
    },
    {
      "Command": "csvSave",
      "Target": "${test}",
      "Value": "!csvLine"
    }
  ]
}

Can you try this, run it and watch the log pane for the blue echo statement - it should write what text has been grabbed, if any.

{
  "Name": "Ishan",
  "CreationDate": "2019-3-7",
  "Commands": [
    {
      "Command": "csvRead",
      "Target": "test2.csv",
      "Value": ""
    },
    {
      "Command": "store",
      "Target": "test.csv",
      "Value": "test"
    },
    {
      "Command": "open",
      "Target": "${!col2}",
      "Value": ""
    },
    {
      "Command": "storeText",
      "Target": "//*[@id=\"homepage\"]/header/div/div[2]/div/h4",
      "Value": "website"
    },
    {
      "Command": "echo",
      "Target": "website text: ${website}",
      "Value": "Blue"
    },
    {
      "Command": "store",
      "Target": "${website}",
      "Value": "!csvLine"
    },
    {
      "Command": "csvSave",
      "Target": "${test}",
      "Value": "!csvLine"
    }
  ]
}

yes true:
[echo] website text: Rocket Internet SE

but it does not save anything in test.csv file.

Weird. Just tried and it worked here.

Do you have XModules installed? If not install.

Is test.csv created in kantu/datasources?

thanks a lot, you are too good, I Installed XModules and it worked and it is saving now.
God Bless You :slight_smile:

Also One Last Question, how it is possible to grab the URL from this code in Website
www.rocket-internet.com

sorry what i mean is the id=“ember66” keeps changing, it is not getting the URL, because sometimes it is ember73, ember88 and so on… so how I can grab the URL

<a id="ember66" rel="noopener noreferrer" target="_blank" href="http://www.rocket-internet.com" class="ember-view">                    www.rocket-internet.com
</a>
1 Like

I’d recommend using full xpath as identifier rather that css element or attribute. It happens in Meta Insights as well and that’s how I solved it.