我正在学习如何解析Beautifulsoup。有人能解释我如何解析div class="article-content"
中的<p></p>
元素。我希望在脚本启动后只能看到内容信息。让我证明我想要的东西:Python Beautifulsoup。解析<p></p>
我可以在<p></p>
解析div class="article-content"
,但不能所需的信息。我的代码看起来这样的方式:
import urllib2
from bs4 import BeautifulSoup
html = urllib2.urlopen('http://www.engadget.com/2014/10/17/local-multiplayer-is-coming-to-android-games/')
parsed_html = BeautifulSoup(html)
print parsed_html.body.find('div', attrs={'class':'article-content'}).text
,但我得到也有很多垃圾:
$ python engadget_parser.py
Ever wish that you could just whip out your Android device and harass a passer-by to play games with you? It's the sort of thing that Nintendo DS users, for example, have been using thanks to that company's StreetPass feature, but, until now, hasn't been available on Google's smartphones. Now, however, the company has an added an update to its games infrastructure that enables "ambient, real-time" games with more than one user - so long that the game relies upon Google's home-grown multiplayer backend. Still, maybe don't sprint into the street and start challenging people to a dual, because they might get the wrong idea.
onBreak({
0: function(){
(function() {
var a = {
mobilePlacementID: "348-14-15-135b",
width: "320",
height: "115"
};
madserver.requestAd(a);
})();
},
768: function(){}
});
Source: Android Developers (G+)
Tags: android, AndroidGames, gaming, google, googleplaygames, mobile, mobilepostcross
Hide Comments
0Comments
_when_.eng("eng.livefyre.init", {
articleId: 20979699 ,
domain: "engadget.fyre.co" ,
siteId: "296092" ,
el: "livefyre_20979699",
initialNumVisible: 2
})
_when_.eng("eng.perm.init");
lab.scriptBs('gravity.js')
onBreak({
0: function(){},
320: function(){},
768: function(){}
});
谢谢!