Extracting an attribute value with beautifulsoup

前端 未结 9 1914
故里飘歌
故里飘歌 2020-11-22 04:38

I am trying to extract the content of a single \"value\" attribute in a specific \"input\" tag on a webpage. I use the following code:

import urllib
f = urll         


        
9条回答
  •  长发绾君心
    2020-11-22 05:35

    I would actually suggest you a time saving way to go with this assuming that you know what kind of tags have those attributes.

    suppose say a tag xyz has that attritube named "staininfo"..

    full_tag = soup.findAll("xyz")
    

    And i wan't you to understand that full_tag is a list

    for each_tag in full_tag:
        staininfo_attrb_value = each_tag["staininfo"]
        print staininfo_attrb_value
    

    Thus you can get all the attrb values of staininfo for all the tags xyz

提交回复
热议问题