Giter Club home page Giter Club logo

texttokenize's Introduction

Golang HTML Text Tokenize - alfa-alfa version

Build Status GoDoc Software License

This don't stable version

Installation

$ go get github.com/mantyr/texttokenize
$ go get github.com/mantyr/goquery

Example

    <div id="main_test2">
        <div class="descriptionText">
            <p>Описание:</p>
            <p>Декоративная шкатулка<p>
            <p style="margin-top:7px;">Цвет: &nbsp;Зелёный, белый</p>
            <p>Материал:&nbsp;<p>Дерево</p> </p><p>Производитель:&nbsp;&nbsp;Россия</p></div>
    </div>
package main

import (
    "github.com/mantyr/texttokenize"
    "fmt"
)

func main() {
    fields := texttokenize.NewTokenize()
    fields.LoadFile("./testdata/valuefields.html")
//    fields.SetIgnoreEmptyLine(true)                // default value "true"
    fields.Parse("#main_test2 .descriptionText p")

    fmt.Println(fields.Get("описание"))       // print "Декоративная шкатулка"
    fmt.Println(fields.Get("цвет"))           // print "Зелёный, белый"
    fmt.Println(fields.Get("материал"))       // print "Дерево"
    fmt.Println(fields.Get("производитель"))  // print "Россия"

    fmt.Println(fields.Get("большой текст"))  // print "line 1\r\nline 2\r\nline 3" or "line 1\r\n\r\nline 2\r\n\r\nline 3" if fields.SetIgnoreEmptyLine(false)
}

Author

Oleg Shevelev

texttokenize's People

Contributors

mantyr avatar

Watchers

James Cloos avatar  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.