Skip to content

Instantly share code, notes, and snippets.

@jonstuebe
Created February 23, 2019 17:28
Show Gist options
  • Save jonstuebe/abee4a3ee13636a86712adc1c3c92c6a to your computer and use it in GitHub Desktop.
Save jonstuebe/abee4a3ee13636a86712adc1c3c92c6a to your computer and use it in GitHub Desktop.
Express Web Scraper
const express = require("express");
const Scaper = require("@jonstuebe/scraper");
const app = express();
const port = 3000;
app.get("/", async ({ query }, res) => {
if (!query.url) {
// handle error here
// res.status(500);
// res.render("error", { error: "url required" });
}
const data = await Scaper.scrapeAndDetect(query.url);
res.send(data);
});
app.listen(port, () => console.log(`listening on port ${port}`));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment