Я очищаю следующий веб-сайт, https://www.trollandtoad.com/magic-the-gathering/aether-revolt/10066,, и я пытаюсь нажать следующую кнопку, чтобы перейти на следующую страницу и очистить ее.Я сделал это на других программах, и поэтому я просто использую тот же код и только что сделал изменения для работы с текущим сайтом, но он не работает.Он только очищает первую страницу.
def parse(self, response):
for game in response.css('div.card > div.row'):
item = GameItem()
item["Category"] = game.css("div.col-12.prod-cat a::text").get()
item["Card_Name"] = game.css("a.card-text::text").get()
for buying_option in game.css('div.buying-options-table div.row:not(:first-child)'):
item["Seller"] = buying_option.css('div.row.align-center.py-2.m-auto > div.col-3.text-center.p-1 > img::attr(title)').get()
item["Condition"] = buying_option.css("div.col-3.text-center.p-1::text").get()
item["Price"] = buying_option.css("div.col-2.text-center.p-1::text").get()
yield item
next_page = response.xpath('//a[contains(., "Next Page")]/@href').get()
# If it exists and there is a next page enter if statement
if next_page is not None:
# Go to next page
yield response.follow(next_page, self.parse)
ОБНОВЛЕНИЕ # 1
Вот снимок HTML-кода для следующей кнопки

ОБНОВЛЕНИЕ № 2
Вот обновленный код, который я должен попробовать и перейти на следующую страницу.Все еще не работает, но я думаю, что я ближе к правильному коду.
next_page = response.xpath('//div[contains(., "Next Page")]/@class').get()
# If it exists and there is a next page enter if statement
if next_page is not None:
# Go to next page
yield response.follow(next_page, self.parse)