I have to scrape meta data as key-value pair from web site.
meta_name = tree.xpath("//meta[@name]/@content")
This will give me value(eg: John Doe) for meta_name but doesn't specify the key(eg:author).
ps: I mentioned example from the uploaded picture
meta_name = tree.xpath("//meta[@name]")
for elem in meta_name:
print(elem.attrib)
elem.attrib will give us the dict of attributes.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.