get-view-state

Extract the view state value from an html page parsed with cheerio

Usage no npm install needed!

<script type="module">
  import getViewState from 'https://cdn.skypack.dev/get-view-state';
</script>

README

Get View State

Extract the view state value from an html page parsed with cheerio

Installation

npm install -S get-view-state

Usage

var inspect = require('eyespect').inspector();
var cheerio = require('cheerio')
var getViewState = require('get-view-state')

// file path to a webpage with a view state element in the html
var filePath = path.join(__dirname, 'data/yesViewState.html') 
var html = fs.readFileSync(filePath, 'utf8')
var $ = cheerio.load(html)

// extract the value attribute from the view state element
var viewState = getViewState($)
inspect(viewState, 'extracted view state')