2012-05-09 17 views
1
import urllib2 
from BeautifulSoup import BeautifulSoup 

result = urllib2.urlopen("http://www.bbc.co.uk/news/uk-scotland-south-scotland-12380537") 
html=result.read() 
soup= BeautifulSoup(html) 
print soup.html.head.title 

print soup.findAll('div', attrs={ "class" : "story-body"}) 

私が欲しい情報はストーリー本体にありますが、底にあります。だから私はそこに着くまでジャンク情報のロードを直してしまう。beautifulsoupでfindAllを使用した結果のフィルタリング

print soup.findAll('p', attrs={ 'class' : "introduction"}) 

のみ私の最初<p>を取得します...だから物語 - 体の端に導入開始から収集するために探して、この例ではすべてのアイデアを

を収集する8以上があるのですか? CSSセレクタの面では

答えて

関連する問題