こんにちは私は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
おかげで、深刻なnoobの誤差が – MethodMan