1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

net.html: fix semantic inconsistencies of tag retrieving functions (#18558)

This commit is contained in:
Turiiya
2023-06-27 19:10:31 +02:00
committed by GitHub
parent 1bae9e4538
commit b2ca3ac089
4 changed files with 65 additions and 39 deletions

View File

@ -12,8 +12,8 @@ fn main() {
}
// html.parse() parses and returns the DOM from the given text.
mut doc := html.parse(resp.body)
// html.DocumentObjectModel.get_tag_by_attribute_value() retrieves all the tags in the document that has the given attribute name and value.
tags := doc.get_tag_by_attribute_value('class', 'list_article_item')
// html.DocumentObjectModel.get_tags_by_attribute_value() retrieves all tags in the document that have the given attribute name and value.
tags := doc.get_tags_by_attribute_value('class', 'list_article_item')
for tag in tags {
el := tag.children[1].children[0].children[0].children[0]
href := el.attributes['href'] or { panic('key not found') }