You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

github.com/alejandrodiazm/html-link-parser-go

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/alejandrodiazm/html-link-parser-go

v0.0.0-20220804093027-3c371dee2b25
Source
Go
Version published
Created
Source

This program written in GoLang (following Jon Calhoun's Gophercise) will iterate through an HTML an parse every link with the attribute "href", returning this value and any text associated with it, in the form of a verbose slice of strings.

There are a few steps you must follow before using the program:

  • First, (and after you've clone the repo, of course), you must run the follwing command to initialize the link module implemented in parse.go, making its methods and typè available to each example.
go mod init link
  • This program uses Go's the html package. Even though its a library developed by Go's engineers, it's not native to the program, so you must install it using the following command:
go get -u golang.org/x/net/html
  • Enjoy! Actually, here's how this works. Each directory in examples/ contains a main.go file, with an example HTML from which to parse the links. There are four examples ready, but if you want to test any other HTML, just assign it as a string to the exampleHtml variable inside main, and you're good to GO. Run the script by using this command:
go run examples/<example_directory_to_test(e.g.ex1)>/main.go  

FAQs

Package last updated on 04 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.