1

I want to make a site (with HTML, CSS and Javascript) which will scrape data from other sites. I want to use javascript in order to accomplish that. Which is the best way to do it? I would like to avoid using Node.js or some other framework.

0

1 Answer 1

3

If you are getting cors error just use cors anywhere.

For dom parsing use DomParser

Example:

fetch(`https://cors-anywhere.herokuapp.com/${url}`)
.then(response => response.text())
.then(html => {
  const parser = new DOMParser()
  const dom = parser.parseFromString(htmlContent, 'text/html')
  // now you can select elements like for normal node
  dom.querySelector('div')
})

Do you have any other problems?

Sign up to request clarification or add additional context in comments.

2 Comments

Konrad thanks for the answer. So are you against of Node.js usage for this purpose?
I'm not against. But hosting a node.js server isn't as simple as hosting a webpage.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.