Extracting an attribute value with beautifulsoup

前端 未结 9 1915
故里飘歌
故里飘歌 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:42

    For me:

    
    

    This can be fetched by below snippet.

    page = requests.get("https://www.abcd.com")
    soup = BeautifulSoup(page.content, 'html.parser')
    colorName = soup.find(id='color')
    print(color['value'])
    

提交回复
热议问题