Saving source with chrome extension


#1

Hello,

Can anyone help me figure out how to do this with the Chrome extension?

Here is what I am trying to do:

  1. Open a web page
  2. Save the source to a local file
  3. Wait an hour
  4. Loop

Thanks in advance.


#2

Currently you can save (extract) parts of the page with sourceExtract, but not yet the whole page. Please see How to SourceExtract the entire html code?


#3

Thanks for the response. I can manage with a general regex to find source. However, I am trying this:

{
  "CreationDate": "2018-6-25",
  "Commands": [
    {
      "Command": "open",
      "Target": "http://www.test.com",
      "Value": ""
    },
    {
      "Command": "sourceExtract",
      "Target": "[<>=-_.:;\"’/û,€éèêçàïëü&|()%!+*’\\’?$\\w\\s]*",
      "Value": "output_html"
    },
    {
      "Command": "localStorageExport",
      "Target": "output_html",
      "Value": ""
    }
  ]
}

I am having trouble understanding how to save the code to a file. It is giving me an error on the last step. What do I specify as the Target and Value?

Thanks!


#4

Great that sourceExtract solves the issue. Now, localStorageExport does not support saving the content of variables yet, but this is on our todo list.

As a workaround, you can assign the variable value to a CSV field (store | var | !csvLine) and then save this CSV file. Of course, a CSV file with only one entry is just a simple text file with the content of your variable, just as needed :wink:

The only drawback of this workaround is that the file extension of the exported file is .csv (and not .txt or .html).

This code snippet extracts a Google Analytics ID and saves it to a text file:

   {
      "Command": "sourceExtract",
      "Target": "regex=UA-[0-9]+-[0-9]+",
      "Value": "ga_option2"
    },
    {
      "Command": "store",
      "Target": "${ga_option2}",
      "Value": "!csvLine"
    },
    {
      "Command": "csvSave",
      "Target": "myHTML",
      "Value": ""
    },
    {
      "Command": "localStorageExport",
      "Target": "myHTML.csv",
      "Value": ""
    },

Note that localStorageExport needs the file extension (“myHTML.csv”), so it knows whether the supplied name refers to a CSV file (from the CSV tab) or an image (from the image tab).


#5

Great info, thanks! Will try it.