How to use Beautiful Soup to extract string in [removed] tag?

后端 未结 4 2014
梦如初夏
梦如初夏 2020-11-28 14:45

In a given .html page, I have a script tag like so:

     

        
4条回答
  •  鱼传尺愫
    2020-11-28 14:56

    You could solve this with just a couple of lines of gazpacho and .split, no regex required!

    from gazpacho import Soup
    
    html = """\
    
    """
    
    soup = Soup(html)
    string = soup.find("script").text
    string.split(".val(\"")[-1].split("\");")[0]
    

    Which would output:

    'name@email.com'
    

提交回复
热议问题