gawel / pyquery

A jquery-like library for python
http://pyquery.rtfd.org/
Other
2.29k stars 182 forks source link

What is the reason why the text method does not get all the text #247

Closed RavenCri closed 1 year ago

RavenCri commented 1 year ago

eg:

ls = '''

 <div class="2" id="1" data="882487640">
    <h3 class="mark_name colorDeep">2. <span class="colorShallow">(单选题,4.0分)</span>
    对功的概念有以下几种说法:<p></p>
        <p>①保守力作正功时,系统内相应的势能增加。</p>
        <p>②质点运动经一闭合路径,保守力对质点作的功为零。</p>
        <p>③作用力与反作用力大小相等、方向相反,所以两者所作功的代数和必为零。</p>
        <p>在上述说法中:</p>
        <p><br>
        </p>
    </h3>
    <ul class="mark_letter colorDeep">

        <li>A. ②、③是正确的。</li>

        <li>B. 只有②是正确的。</li>

        <li>C. 只有③是正确的。</li>

        <li>D. ①、②是正确的。</li>
    </ul>
 </div>

'''

jq = PyQuery(ls)
print(jq.find('h3').text())

The text of the p tag is not printed, why, image

RavenCri commented 1 year ago

I found the answer. Thank you: https://github.com/gawel/pyquery/issues/237#issuecomment-1366692092