ahmadrosid / greph

🔭 It's like grep but for html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Greph

Just like grep but for html document.

Demo

Install

Clone repository :

git clone https://github.com/ahmadrosid/greph.git

Compile :

go test
go build
go install

Usage

Grep from url :

greph https://example.com "p[0].text"

Grep from stdin :

echo "<p>Paragraph</p>" | greph "p[0].text"

Query

Format selector[index]extractor.

Selector

Select by tag :

echo "<p>Paragraph</p>" | greph "p[0].text"

Select by class :

echo "<h1 class="title">Title</h1>" | greph ".title[0].text"

Index

Get one from index 0:

greph https://example.com "p[0].text"

Get all bwtween index 2 and 5:

greph https://example.com "p[2:5].text"

Get all until index 5:

greph https://example.com "p[:5].text"

Extractor

Extract the text from tag :

echo "<p>Paragraph</p>" | greph "p[0].text"

Extract the text from attributes :

echo "<a href="https://example.com">Title</h1>" | greph "a[0]:href"

About

🔭 It's like grep but for html


Languages

Language:Go 100.0%