Coder Social home page Coder Social logo

html-parser's Introduction

html-parser2

学习参考,用于爬虫

/**
  作者:阮家友
  时间:2017-5-12 10:53:43
  说明:html Node节点对象
**/

安装方法

npm install html-parser2 -s

使用

const { HTML, Node, $ } = require('html-parser2');
let str = '<!--代码如诗 , 如痴如醉 !--><html xmlns:wb="http://open.weibo.com/wb"><title>xxx</title><body><p>yes<img src="https://www.google.com/favor.icon"/></p></body></html>';
let doc1 = new HTML(str);
// 1.
console.log($(doc).find('p > img').attr('src'));
console.log($(doc).find('p').find('img').attr('src'));
// 2.
console.log(doc.$('p > img').attr('src'));

TODO

  • 覆盖率测试
  • 增加并完善测试 case
  • svg 处理

html-parser's People

Contributors

ruanjiayou avatar

Stargazers

masx200 avatar

Watchers

James Cloos avatar

html-parser's Issues

解析错误 含有"-"的标签名

解析错误 含有"-"的标签名

const{default:temp1}=await import('https://esm.sh/[email protected]')
console.log(new temp1(`<mjx-container
  class="MathJax"
  jax="CHTML"
  style="font-size: 122.3%"
  display="true"
  ></mjx-container>
`).Root.innerHTML)
<mjx container="" class="MathJax" jax="CHTML" style="font-size: 122.3%" display="true"></mjx>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.