Quote:
lists = soup.find_all('div',class_="s-main-slot s-result-list s-search-results sg-row")
Look at the returned HTML - there is only one
<div class="s-main-slot ...">
element.
Your code loops over that one element, and finds the first name and price spans within the entire list.
Change your code to find all
<div class="s-result-item ...">
items instead, and you might have better luck:
lists = soup.select("div.s-result-item")
NB: use
select
rather than
find_all
, since you can't specify the full
class
attribute, as it changes for each element.
Alternatively, use the
data-component-type
attribute to find the search result items:
lists = soup.select('div[data-component-type="s-search-result"]')