Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter out HTML and JSON #1

Open
jorendorff opened this issue Sep 5, 2019 · 0 comments
Open

Filter out HTML and JSON #1

jorendorff opened this issue Sep 5, 2019 · 0 comments

Comments

@jorendorff
Copy link

For some reason, scrapper gathers a lot of stuff that is not JS.

If JSON.parse(sourceText) succeeds then we definitely don't care about it.

HTML is harder to pin down; it's wrong to search for tags, because many JS files contain globs of HTML, for use with .innerHTML.

One solid indicator of HTML is <!doctype or <html at the start of the file.

You can detect whether a string matches Script by doing new Function("", sourceText) and catching the SyntaxError. But it throws for modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant