Created
February 23, 2019 17:28
-
-
Save jonstuebe/abee4a3ee13636a86712adc1c3c92c6a to your computer and use it in GitHub Desktop.
Express Web Scraper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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