Scraping Ebay, working until I use it in sold items

  beautifulsoup, python, scrape, web-scraping

I will use this code to explain my doubt:
Using the url without sold filter

import requests
from bs4 import BeautifulSoup
import pandas as pd
import numpy as np

url = "https://www.ebay.es/sch/i.html?_from=R40&_trksid=p2334524.m570.l1313&_nkw=iphone+x&_sacat=0&LH_TitleDesc=0&_udlo=400&LH_Auction=1&_osacat=0&_odkw=Pok%C3%A9mon+card+Charizard+4%2F102&rt=nc"
r = requests.get(url)
soup = BeautifulSoup(r.text, "html.parser")

results = soup.find_all("div", {"class": "s-item__info clearfix"})
print(len(results))

Output: 12

Then I use the url where there are only sold items, I check the html and the class is the same.

import requests
from bs4 import BeautifulSoup
import pandas as pd
import numpy as np

url = "https://www.ebay.es/sch/i.html?_from=R40&_nkw=iphone+x&_sacat=0&LH_TitleDesc=0&_udlo=400&LH_Auction=1&rt=nc&LH_Sold=1&LH_Complete=1"
r = requests.get(url)
soup = BeautifulSoup(r.text, "html.parser")

results = soup.find_all("div", {"class": "s-item__info clearfix"})
print(len(results))

Output: 0

I tries different classes but I can´t never obtain something.
Thanks.

Source: Python Questions

LEAVE A COMMENT