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

[POST] How to parse html response without loading any images #23

Open
Rplus opened this issue Mar 17, 2016 · 0 comments
Open

[POST] How to parse html response without loading any images #23

Rplus opened this issue Mar 17, 2016 · 0 comments
Labels

Comments

@Rplus
Copy link
Owner

Rplus commented Mar 17, 2016

How to parse html response without loading any images
by Michal Pierzchala 2015-08-12
https://www.xfive.co/blog/how-to-parse-html-response-without-loading-any-images/

找東西時找到這篇蠻有興趣的文章
他希望做到的就是 parse HTML source code 時不觸發額外的 request

keypoint: document.implementation.createHTMLDocument()
https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument

這在處理 template 或是 把 HTML ajax 進來後的處理,
有很大的幫助
因為可以不觸發一堆 request 就把要的東西爬出來

這創建出來的 HTMLDocument
仍然可以用一般的 querySelector, getElement... 之類的 node method
非常棒~


test page:
https://jsbin.com/fixahi/1/edit?js,output

support: IE9+


tw: https://twitter.com/RplusTW/status/710184068550414337
fb: https://www.facebook.com/rplus.tw/posts/1077852872282495

@Rplus Rplus added the 筆記 label Mar 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant