Objective c 从HTMLKit中的HTMLDocument获取href
我正在尝试从HTMLKit()中的HTMLDocument获取属性href 代码如下:Objective c 从HTMLKit中的HTMLDocument获取href,objective-c,Objective C,我正在尝试从HTMLKit()中的HTMLDocument获取属性href 代码如下: HTMLDocument *document = [HTMLDocument documentWithString:tempPage]; NSArray *articles = [document querySelectorAll:@"div.inner-article>a"]; for(HTMLDocument *article in articles){ printf("%s\n\n", [
HTMLDocument *document = [HTMLDocument documentWithString:tempPage];
NSArray *articles = [document querySelectorAll:@"div.inner-article>a"];
for(HTMLDocument *article in articles){
printf("%s\n\n", [article.outerhtml UTF8String]);
}
文档对此不是很清楚。我可以清楚地看到带有此for循环的href,但我需要进一步提取它。谢谢您需要访问属性字典,类似于:
let allAElements = htmldoc.querySelector("[class^='styles_tagcloud']")?.querySelectorAll("a")
allAElements!.forEach({ (element) in
print("Href >>> ", element.attributes.value(forKey: "href"))
})