1

I'm kind of new to node.js and Javascript so forgive me if the question is poorly worded.

I'm using cheeriojs to scrape data from a site. I'm running the js file that scrapes the data in the command line and it outputs the data I want, but I want to be able to have access to this data on a webpage, where I can put it into a table. (or anything else I want for that matter). How exactly do I do this?

Thank you

hhaammzzaa2
  • 27
  • 1
  • 7
  • Can you add some examples of what you mean? Like a simple use case. From what I can understand, you have scraped a page using cheeriojs using nodejs, however you want to serve a webpage to a browser using nodejs, edit the webpage that is served to the browser, send it back to nodejs, and save it? – jmunsch Jul 30 '16 at 00:05
  • Yes, that sounds like what I'm trying to do. – hhaammzzaa2 Jul 30 '16 at 00:09

1 Answers1

1

Learn how to use express.

Serve the page to a browser, by reading the file and serving it with an express endpoint, or to curl or something. ie curl localhost:8080/your-endpoint

Using the browser manipulate the page inside of the browsers dev tools.

Figure out how to get the current DOM as an html string.

Figure out how to use the fetch API inside of a browser such as fetch(url, {method: 'POST'}).then(...)

After manipulating the DOM with the browsers dev tools.

POST the results back to express on the nodejs server.

Save the req.body or req.data or req.params to a file.

Side notes: - figure out what a callback is, figure out how promises work - do some research on express middleware - look into setInterval, setTimeout

Related:

Other options, use a text editor, use sed, grep, awk, bash, or something else that doesn't require serving files to a browser?

Community
  • 1
  • 1
jmunsch
  • 22,771
  • 11
  • 93
  • 114