Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
The Code is ok. I am running this in Pycharm.
I ve already installed requests and beautifulsoup4 library as well.
But I am not getting the output, what do I change

Code -

import requests
from bs4 import BeautifulSoup


def scrape_ebay_puzzles():
    url = "https://www.ebay.com/b/Puzzles/2613/bn_1865244"
    page = requests.get(url)
    soup = BeautifulSoup(page.content, "html.parser")
    results = soup.find_all("li", class_="s-item")

    for result in results:
        title = result.find("h3", class_="s-item__title").text
        price = result.find("span", class_="s-item__price").text
        print(f"Title: {title}")
        print(f"Price: {price}")


if __name__ == "__main__":
    scrape_ebay_puzzles()


Output is blank.

What I have tried:

The Code is ok. I am running this in Pycharm.
I ve already installed requests and beautifulsoup4 library as well.
But I am not getting the output, what do I change 
Posted
Updated 1-Feb-23 13:12pm
Comments
Richard MacCutchan 31-Jan-23 5:17am    
Start by adding some print statements to your code to check exactly what is getting returned at each step. Alternatively, run the code in the debugger and step through it to check.

Why are you going with web scraping instead of just using eBay's API[^]?
 
Share this answer
 
I was trying your code. It's OK, but the process seems to be stuck...

I've tried to change request with adding timeout parameter:
Python
try:
    page = requests.get(url,timeout=60)
except requests.exceptions.RequestException as e:
    raise SystemExit(e)

and i get:
SystemExit: HTTPSConnectionPool(host='www.ebay.com', port=443): Read timed out. (read timeout=60)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900