Python 用靓汤提取文本

Python 用靓汤提取文本,python,beautifulsoup,Python,Beautifulsoup,我想提取的文本从这个html使用bs4,我是新的,似乎不能得到它,任何帮助非常感谢 <div class="results"> <span class="toggle" ng-click="display.toggleConfig()">{{display.configText}}</span> <p ng-hide="insecure">It would take <span ng-sho

我想提取的文本从这个html使用bs4,我是新的,似乎不能得到它,任何帮助非常感谢

<div class="results">
            <span class="toggle" ng-click="display.toggleConfig()">{{display.configText}}</span>


            <p ng-hide="insecure">It would take <span ng-show="config.calculationsOriginal">a desktop PC</span> about <span class="main">{{time}}</span> to crack your password</p>
            <a class="tweet-me" ng-hide="insecure" href="http://twitter.com/home/?status=It would take a desktop PC about {{time}} to crack my password!%0d%0dhttp://hsim.pw">[Tweet Result]</a>

            <p ng-show="insecure">Your password would be cracked almost <span class="main">Instantly</span></p>
            <a class="tweet-me" ng-show="insecure" href="http://twitter.com/home/?status=My password would be cracked almost instantly!%0d%0dhttp://hsim.pw">[Tweet Result]</a>

            <span class="toggle" ng-click="display.toggleDetails()">{{display.detailsText}}</span>
        </div>

        <ul ng-show="display.details">
            <li><strong>Length:</strong> {{length}} characters</li>
            <li><strong>Character Combinations:</strong> {{characters}}</li>
            <li><strong>Calculations Per Second:</strong> {{calcsPerSecond}}</li>
            <li><strong>Possible Combinations:</strong> {{possibleCombinations}}</li>
        </ul>

        <ul ng-show="checks">
            <li ng-repeat="check in checks" class="{{check.type}}">
                <h2 ng-bind-html-unsafe="check.title"></h2>
                <p ng-bind-html-unsafe="check.wording"></p>
            </li>
        </ul>

有点不清楚时间在html中的实际位置,但它看起来像是在带有
class=“main”
中。其中有两种,可轻松提取:

for x in soup.findAll("span",{"class":"main"}):
    print x.text
给出:

{{time}}
Instantly
如果需要对象中的所有文本,请尝试:

soup.get_text()

它将递归地从对象及其子对象中提取所有文本。

我正在使用selenium并使用bs4 soup=beautifulsou(browser.page_source)#示例使用CSS选择器crack_time=soup提取破解时间。选择('results')打印破解时间[0]。textHello@pam,欢迎访问该网站!您似乎很难在StackOverflow上提出好的问题。我建议您在遇到与编程相关的特定问题时阅读并返回。
text=[s.text代表汤中的s.find_all('p')]
不用担心,不客气,我已将您尝试的代码添加到您的问题中,如果您添加了您尝试添加的代码,当您提出问题时,它将对您有所帮助。我们不要将注释部分变成问答。这种风格是IRC发明的目的,而不是Stackexchange。
soup.get_text()