Skip to main content

scraping module

this module called frontend scraping is a relatively new module that allows us to use web scraping for the client side as we do in the backend.

use a vercel with a request parameter whether to use get or post weighs less than 1KB

scraping module using serverless node backend code.

browser

<!--main file-->
<script src="https://cdn.jsdelivr.net/npm/neo-jquery/browser/scraping.js"></script>

module

/* CJS */
const { $scraping } = require('neo-jquery/core/scraping')

/* ESM */
import { $scraping } from 'neo-jquery/core/scraping'

/* async/await and top level await*/
const { $scraping } = await import('neo-jquery/core/scraping')

dynamic import is compatible with neo-jquery CJS

using scraping module

$scraping({
url: 'https://example.com',
web(data) {
console.info(data)
},
failed(err) {
console.error(err)
}
})
desctype
params: { url, web, failed }scraping
returnPromise<void>

scraping type params

propietytype
urlstring
web(param: Document) => void
failed(param: any) => void

similar to $ajax only DOM data