Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var LookupTable = [...]string{
"//*[@id=\"business-unit-title\"]/h1/span[1]",
"//*[@id=\"business-unit-title\"]/span[1]/span",
"//*[@id=\"business-unit-title\"]/div/div/p",
"//*[@id=\"business-unit-title\"]/div/div/div/img",
}
Functions ¶
This section is empty.
Types ¶
type Result ¶
type Result struct {
Company string // The company name
Reviews struct {
Total string // Total amount reviews
Text string // Description text
}
ImageSRC string // The SVG of the star rate graphical vector
}
func Parse ¶
func Parse(body io.ReadCloser) (*Result, error)
Parse parses the HTML content from the given io.ReadCloser and returns a Result struct and an error.
It takes a parameter `body` of type `io.ReadCloser` which represents the HTML content.
The function first parses the HTML content using the `htmlquery.Parse` function. If there is an error during the parsing, it returns the error.
Then, it initializes an empty `Result` struct.
Next, it iterates over the `LookupTable` and performs different operations based on the index.
- If the index is 0, it sets the `Company` field of the `Result` struct to the inner text of the parsed node. - If the index is 1, it sets the `Text` field of the `Reviews` struct to the inner text of the parsed node. - If the index is 2, it sets the `Total` field of the `Reviews` struct to the inner text of the parsed node. - If the index is 3, it sets the `ImageSRC` field of the `Result` struct to the value of the "src" attribute of the parsed node.
Finally, it returns a pointer to the `Result` struct and a `nil` error.
func (*Result) GetCompanyName ¶
GetCompanyName returns the name of the company.
This function takes no parameters and returns a string representing the name of the company.
func (*Result) GetReviewsText ¶
GetReviewsText returns the text of the reviews.
It does not take any parameters. It returns a string.
func (*Result) GetTotalReviews ¶
GetTotalReviews returns the total number of reviews.
It does not take any parameters. It returns a string.