擅长:python、mysql、java
<p>正如您的错误所说,您试图调用列表上的<code>.xpath(..)</code></p>
<pre><code>headlineNode = doc.xpath('//div[@class="headline"]')
len(headlineNode)
# ^ headlineNode is a list, I guess you know this.
</code></pre>
<p>现在</p>
^{pr2}$
<p><strong>修复</strong>:</p>
<p>你需要说:</p>
<pre><code>headlines = headlineNode[0].xpath('/a')
</code></pre>
<p>考虑将变量名重命名为<code>headlineNodes</code>以避免混淆,或者说:<code>headlineNode = doc.xpath(..)[0]</code>(这可能会引发异常)。在</p>