Giter VIP home page Giter VIP logo

htmlparser's Introduction

htmlparser

delphi html parser

代码是改自原wr960204的HtmlParser,因为自己的需求需要对html进行修改操作,但无奈只支持读取操作,所以在此基础上做了修改并命名为HtmlParserEx.pas与之区别。

修改记录

ying32修改于 2016年11月15日
Email:[email protected]

IHtmlElement和THtmlElement的改变:
1、Attributes属性增加Set方法
2、TagName属性增加Set方法
3、增加Parent属性
4、增加RemoveAttr方法
5、增加Remove方法
6、增加RemoveChild方法
7、增加Find方法,此为SimpleCSSSelector的一个另名
8、_GetHtml不再直接附加FOrignal属性值,而是使用GetSelfHtml重新对修改后的元素进行赋值操作,并更新FOrignal的值
9、增加Text属性
10、修改InnerText与Text属性增加write功能 11、增加AppedChild方法

IHtmlElementList和THtmlElementList的改变:
1、增加RemoveAll方法
2、增加Remove方法
3、增加Each方法
4、增加Text属性

修改后的新功能的一些使用法

IHtmlElement

     // 修改属性
     EL.Attributes['class'] := 'xxxx';
     // 修改标记
     EL.TagName = 'a';
     // 移除自己
     EL.Remove; 
     // 移除子结点
     EL.RemoveChild(El2);
     // css选择器查找,简化用
     El.Find('a');
     // 附加一个新的元素
     el2 := El.AppendChild('a');
     
     

IHtmlElementList

  // 移除选择的元素
  LHtml.Find('a').RemoveAll;

  // 查找并遍沥
  LHtml.Find('a').Each(
    procedure(AIndex: Integer; AEl: IHtmlElement)
    begin
      Writeln('Index=', AIndex, ',  href=', AEl.Attributes['href']);
    end);

  // 直接输出,仅选中的第一个元素
  Writeln(LHtml.Find('title').Text);

htmlparser's People

Contributors

ying32 avatar

Watchers

 avatar  avatar

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.