你好,我是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