标签: python beautifulsoup
尝试从另一个查找的结果中找到但是收到此错误 这是代码片段:
soup =BeautifulSoup(html, "lxml") gameArea = soup.find("div", {"id": "gamefilearea"}) gameObject = gameArea.find("object")
<section id="gamearea"> <div id="gamefilearea" class="" style="height:424px;"> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdowns.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="585" height="424" id="gamefile" align="middle"> <param name="allowScriptAccess" value="always"> <param name="movie" value="http://cache.games.com/files/games/17971.swf"> <param name="quality" value="high"> <param name="wmode" value="window"> <param name="allowfullscreen" value="false"> <param name="allowfullscreeninteractive" value="false"> <param name="fullScreenAspectRatio" value=""> <param name="quality" value=""> <param name="play" value="false"> <param name="loop" value="false"> <param name="menu" value="false"> <param name="flashvars" value="gameID=17971"> <param name="hasPriority" value="true"> <embed src="http://games.com/files/games/17971.swf?v=1456132501" quality="high" width="585" height="424" id="gamefileEmbed" name="gamefile" align="middle" wmode="window" allowfullscreen="false" allowfullscreeninteractive="false" fullscreenaspectratio="" play="false" loop="false" menu="false" allowscriptaccess="always" flashvars="gameID=17971" haspriority="true" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer"> </object> </div> <script> var removeAdSwf = function() { startPlayCounter(); jQuery('#afg_preloader').remove(); jQuery('#gamefilearea').removeClass('afg-running prestitial-running'); }; var noAdsReturned = function () {removeAdSwf();}; </script>
从这里尝试选择对象元素
答案 0 :(得分:0)
解决了它。 在我的情况下,查找操作正在循环中执行,在少数情况下,首先查找操作返回None,因为第二次查找返回错误。
感谢您的帮助