擅长:python、mysql、java
<p>从您的代码中,似乎您正在for循环中调用scraper函数来打印链接。只要把它移到for循环之外,就可以了。你知道吗</p>
<pre><code>def scraper(pageNum):
req = Request("http://www.someurl.com/Search/page="+str(pageNum)+"&facet_Category=20", headers={"User-Agent": "Mozilla/5.0"})
html = urlopen(req).read()
bsObj = BeautifulSoup(html)
for result in bsObj.select("h2 a"):
print(result["href"])
scraper(pageNum+1)
</code></pre>