2017-07-24 29 views
-1
[<input class="mail opentip" 
     data-original-title="Your temporary Email address" 
     data-placement="bottom" 
     id="mail" 
     onclick="select(this);" 
     readonly="" 
     title="" 
     type="text" 
     value="[email protected]"/>] 

我如何可以提取使用beautifulsoup電子郵件中BeautifulSoup值:「[email protected]如何提取也將被隱藏

+2

的可能的複製[使用beautifulsoup提取屬性值](https://stackoverflow.com/questions/2612548/extracting-an-attribute-value-with-beautifulsoup) – kristaps

+0

用途:'soup.find('input',{'id':'郵件 '})得到(' 值')' –

回答

0

,你可以這樣做:

from bs4 import BeautifulSoup 
text = '''<input class="mail opentip" data-original-title="Your temporary Email address" data-placement="bottom" id="mail" onclick="select(this);" readonly="" title="" type="text" value="[email protected]"/>''' 

parse = BeautifulSoup(text, 'lxml') 

for z in parse.find_all('input', {'class':"mail opentip"}): 
    print(z['value'])