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.

asked Aug 23, 2020 at 16:45
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?

answered Aug 24, 2020 at 13:16
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

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.