テーブルスクレーパーを作成しようとしていますが、このコードを書きましたhttp://pastebin.com/t1wSPvbb しかし、テキストでのデータの保存に問題があり、10ページ後にスクレーパーは同じデータを保存します
これは問題のコードです:
for num in range(1,500):
print num
try:
resp = ''
resp = opener.open("http://login.site.com/view.asp?view&PAGE="+str(num))
soup = BeautifulSoup(resp.read())
for tr in soup.find_all('tr')[3:]:
tds = tr.find_all('td')
outfile.write (tds[2].text.encode('utf-8','replace') + ',' + tds[0].text.encode('utf-8','replace') + ',' + tds[1].text.encode('utf-8','replace') + '\n')
pass
except:
pass
10 ページの後、スクレーパーは次の数ページに対して同じデータを保存します。