From 1f39fc7dc8aebb56c3717e9fc599ca9ee6b282ef Mon Sep 17 00:00:00 2001 From: arsam Date: Fri, 18 Sep 2026 23:19:01 +0330 Subject: [PATCH] Import source: parser/parser Import the existing local project snapshot. This commit organizes existing files; it does not represent newly developed functionality. --- parser/parser.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 parser/parser.go diff --git a/parser/parser.go b/parser/parser.go new file mode 100644 index 0000000..aa532fe --- /dev/null +++ b/parser/parser.go @@ -0,0 +1,23 @@ +package parser + +import "io" + +// QueryAttrMap stores a mapping of parser query and an attribute which data +// should be retrieved. Example: QueryAttrMap{"div": "class"}. Here div elements +// should be found and the class value of each will be collected. +type QueryAttrMap map[string]string + +// QueryResult stores all results parsed using the QueryAttrMap value. For preventing +// data duplicates the values are stored in a map structure. +type QueryResult map[string]struct{} + +// Parser describes a generic set of parser functions. +type Parser interface { + // FindContent searches for only one element and returns its text content. + FindContent(r io.Reader, query string) (string, error) + + // FindAttrMap searches by multiple queries and retrieves corresponding attributes + // of found elements. All queries and related attributes stores within QueryAttrMap. + // All results will be stored in QueryResult. + FindAttrMap(io.Reader, QueryAttrMap, QueryResult) error +}