Giter VIP home page Giter VIP logo

htmlparser's Introduction

Tip: Only for .net,use with https://github.com/JieNiGui06/JType

Explain:

Install: dotnet add package htmlparser_light --version 1.0.0.4
Or search at vsNugetManage: htmlparser_light
Or goto the website: NuGet Gallery | htmlparser_light 1.0.0.4

Code Example (C#):

1. HTMLParser.HtmlNode htmlNode = new HTMLParser.HtmlNode("\r\n<a id=\"dd\" href=\"dssgg1111\" href=\"dgeargerghrahfd1111\" / >\r\n<!--\r\n \"\"\r\n-->\r\n<a class=\"outc\" href=\"dsvfz\">\r\n <a id=\"inna\" href=\"adfsgrg\">\r\n <a class=\"sssss\" id=\"innad\" href=\"adfsgrg\">\r\n\r\n <\/a>\r\n\r\n <\/a>\r\n<\/a>\r\n<img name=\"img\" class=\"iimg\" src=\"你正则表达式写的也太好了!!!\" alt=\"agsc\"><\/img>");
var requrl = htmlNode["img", UniqueTags._name].GetProperty("src");

Console.WriteLine(requrl);

requrl = htmlNode.GetChildByUniqueTags("img", UniqueTags._name).GetProperty("src");
Console.WriteLine(requrl);
requrl = htmlNode[new string[]{"innad","sssss"},UniqueTags._id|UniqueTags._class].GetProperty("href");
Console.WriteLine(requrl);
requrl = htmlNode["inna"]["innad"].GetProperty("class");
Console.WriteLine(requrl);
return;

Output:

你正则表达式写的也太好了!!!
你正则表达式写的也太好了!!!
adfsgrg
sssss

2. HttpClient httpClient = new HttpClient();
string roothtml = await httpClient.GetStringAsync($"https://cn.bing.com/search?q=SPDX+License+List%E6%80%8E%E4%B9%88%E5%86%99&qs=n&form=QBRE&sp=-1&lq=0&pq=spdx+license+list%E6%80%8E%E4%B9%88%E5%86%99&sc=1-20&sk=&cvid=B041837E3D4B4A8686B8A8A6F2F3566C&ghsh=0&ghacc=0&ghpl=");
HTMLParser.HtmlNode htmlNode = new HTMLParser.HtmlNode(roothtml);
var requrl = htmlNode["sb_form_q"].GetProperty("placeholder");
Console.WriteLine(requrl);
return;

Output:

有问题尽管问我...

3. HTMLParser.HtmlNode htmlNode = new HTMLParser.HtmlNode("\r\n<a id=\"dd\" href=\"dssgg1111\" href=\"dgeargerghrahfd1111\" / >\r\n<!--\r\n \"\"\r\n-->\r\n<div class=\"outc\" href=\"dsvfz\">\r\n <a id=\"inna\" href=\"adfsgrg\">\r\n <a class=\"sssss\" id=\"innad\" href=\"adfsgrg\">\r\n\r\n <\/a>\r\n\r\n <\/a>\r\n<\/div>\r\n<img name=\"img\" class=\"iimg\" src=\"你正则表达式写的也太好了!!!\" alt=\"agsc\"><\/img>");
var requrl = htmlNode["outc", UniqueTags._class].ByTypes()["a"].GetProperty("id");
Console.WriteLine(requrl);

Output:

inna

htmlparser's People

Contributors

jienigui06 avatar

Watchers

 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.