Extract Data from a website

Hi @Pratik_Shah,

So, here's what I came up with:

It uses two methods:

  1. Pasting the data into the paragraph field
  2. Typing the snippet shortcut inside a text field on the website itself where you want to extract the data

There's a note inside the snippet that says:

The snippet is currently using the first method. For illustration purposes, I included sample data from the page you gave me as a default for the {formparagraph} command. However, you can easily change it to:

{formparagraph: name=sampledata; cols=80; rows=20; default={clipboard}}

This will automatically grab whatever is in your computer clipboard.

If you want to use the second method, you need to follow the instruction inside the snippet where it says the following:
"In here, change sampledata to rawdata if you want to use the selector"

Essentially what I'm doing in the snippet is:

  • Grabbing the data using one of the two methods
  • Splitting the data by linebreak (represented by "\n"), which turns it into a list
  • Using the map() function to break each list item into two items by tab-stop (represented by "\t"). This turns my list into a "list of lists"
  • Turning every item pair into a key and a value so that the main list becomes a keyed list
  • Using the keys in that list as values in my {formmenu} and then giving out the corresponding result.

There's quite a bit to chew on in there, so don't worry if you get stuck. I'm happy to explain anything you find unclear.

On a final note, the {urlload} command won't work in this scenario, as the url is always the same regardless of the record, so we can't pull a particular record by loading its unique URL.