如题,爬取数据过程中用append添加每一页数据,总共100页,最后发现是最后一页的数据重复了一百遍。出现这种的问题的原因一般是什么?谢谢。
def parsePage(ilt,html):
soup=BeautifulSoup(html,"html.parser")
ul=soup.find('ul','pt5 izixun-newZixunList')
a=ul.find_all('a')
for i in range(len(a)):
href=a[i].attrs['href']
if("kanbing" in href):
ilt.append(href)
return ilt
def main():
depth=100
list_url=""
infoList=[]
#recordList=[]
for i in range(1,depth+1):
try:
listUrl=list_url+str(depth)
headers={}
html=requests.get(listUrl,headers=headers)
infoList=parsePage(infoList, html.text)
#print(i)
except:
continue
main()