extracting data from a piece of javascript


I am trying to scrape a website and I need to extract data that is in the javascript of the source code into a table. It looks something like this:

{ langId: 31, storeId: 30019, catalogId: 10158, categoryId: "28578", urlLangId: 31, pageSize: 48, pageNumber: 1, beginIndex:0, sType: "SimpleSearch", searchTerm: "", searchType: "", metaData: "", resultCatEntryType: "", filterFacet: "", manufacturer: "", searchTermScope: "", filterTerm: "", filterType: "", advancedSearch: "", selection: { colour: [], size: [] } } }); }); });

		<p>I want to have 1 row with the headers that are in in front of the&nbsp;&quot;:&quot;&nbsp;and the values the piece between the &quot;:&quot; and the &quot;,&quot;. I need an elegant way of doing this.</p>

		<p>I tried to convert the string to JSON but I got an error that the field names arent double qouted.</p>

		<p>Thanks for the support!</p>

		<p>Kind regards,</p>


Hi Anton,

using the JSON node is the right aproach to do this in an elegant way. To prepare the string i.e. the value with double quote I think you need to use the Java Snippet node and do some string manipulation.

Cheers, Kilian

One can use Java's JavaScript execution engine and then create a JSON string which can then be parsed by the JSON nodes. Something like this:

Table Creator

Before, make sure to clean the input string before, so that brackets are balanced (your example contains more closing than opening brackets).

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.