擅长:python、mysql、java
<p>一般来说,lxml比beautifulsoup好得多</p>
<pre><code>import requests
from lxml
import html
url = "xxxx"
r = requests.get(url)
tree = html.fromstring(r.text)
rows = tree.xpath('//div[@class="lister-item mode-detail"]')
for row in rows:
description = row.xpath('.//div[@class="ratings-bar"]/following-sibling::p[@class="text-muted"]/text()')[0].strip()
</code></pre>