2014-10-03 101 views
0

我有一段特定的文本,我试图使用BeautifulSoup和Python,但是我不知道如何使用sou.find()来获取它。在beautifulsoup中找到特定文本

我想从下面获得“#1美容”。

<ul> 
<li>...<li> 
<li>...<li> 
<li id="salesRank"> 
    <b>Amazon Best Sellers Rank:</b> 
    "#1 in Beauty (" 
    <a href="http://www.amazon.com/gp/bestsellers/beauty/ref=pd_dp_ts_k_1"> See top 100</a> 
    ") 

任何人都可以帮助我吗?

回答

0

您需要使用soupfind_all方法。下面试试

import urllib, urllib2 
from bs4 import BeautifulSoup, Comment 
url='your url here' 
content = urllib2.urlopen(url).read() 
soup = BeautifulSoup(content, "html.parser") 
print soup.find_all('#1 in Beauty') 
相关问题