擅长:python、mysql、java
<p><code>len(nextpage)</code>永远不会改变,因此while循环永远不会结束,并且最终<code>counter</code>索引会超过<code>nextpage</code>的结尾。相反,请执行以下操作:</p>
<pre><code>for page in nextpage:
for price in olxprices:
output.append(price.get_text().strip())
print(price.get_text().strip())
newUrl = page['href']
olxprices = Olx(newUrl).getPrice()
</code></pre>