你好,我是Python新手,想弄清楚为什么我的列表每当新的页面在while循环中被加载和刮取时都会覆盖前面的元素。先谢谢你。Python - 之前的列表元素在while循环期间被新元素覆盖
def scrapeurls():
domain = "https://domain234dd.com"
count = 0
while count < 10:
page = requests.get("{}{}".format(domain, count))
soup = BeautifulSoup(page.content, 'html.parser')
data = soup.findAll('div', attrs={'class': 'video'})
urls = []
for div in data:
links = div.findAll('a')
for a in links:
urls.append(a['href'])
print(a['href'])
print(count)
count += 1
举动'urls'列表出来的'while'循环 – RomanPerekhrest
感谢,严重的小白错误 – MethodMan