From 859542119e55fc7abb394609868f3cf4cb4e72d2 Mon Sep 17 00:00:00 2001 From: localhorst Date: Wed, 11 Jan 2023 19:18:48 +0100 Subject: [PATCH] fix auction listings --- compare.py | 4 ++-- scrape_listing.py | 6 ++++-- search_eBay.py | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/compare.py b/compare.py index 2452ef6..c3db57b 100644 --- a/compare.py +++ b/compare.py @@ -71,8 +71,8 @@ if __name__ == "__main__": if competitor_listing_data: #print(competitor_listing_data["price"]) - if competitor_listing_data["price"] < seller_listing_data["price"]: - #print("found cheaper competitor: " + str(competitor_listing_data["price"]) + "€ instead: " + str(seller_listing_data["price"]) + "€ ---> " + competitor_listing_url) + if (competitor_listing_data["price"] < seller_listing_data["price"]) and (competitor_listing_data["directbuy"] == True): + #print("found cheaper competitor: " + str(competitor_listing_data["price"]) + "€ instead: " + str(seller_listing_data["price"]) + "€ ---> " + competitor_listing_url + " Type: "+ str(competitor_listing_data["directbuy"])) cheaper_listings.append({ 'title': competitor_listing_data["title"], 'price': competitor_listing_data["price"], diff --git a/scrape_listing.py b/scrape_listing.py index db82809..347d289 100644 --- a/scrape_listing.py +++ b/scrape_listing.py @@ -28,11 +28,13 @@ def scrape_listing(url): soup = make_soup(url) #print(soup) #print(soup.find("div", class_="vim x-item-title").span.text) + #print(soup.find("span", class_="ux-call-to-action__text").text) #print(soup.find("span", itemprop="price")["content"]) #print(soup.find("img", itemprop="image")["src"]) listing = { 'title': soup.find("div", class_="vim x-item-title").span.text, + 'directbuy' : True if soup.find("span", class_="ux-call-to-action__text").text == "Sofort-Kaufen" else False, 'price': float(soup.find("span", itemprop="price")["content"]), 'image': soup.find("img", itemprop="image")["src"], 'url' : url @@ -40,7 +42,7 @@ def scrape_listing(url): return listing if __name__ == "__main__": - while(1): - listing = scrape_listing("https://www.ebay.de/itm/165841583057") + #while(1): + listing = scrape_listing("https://www.ebay.de/itm/225333003766") print(listing) diff --git a/search_eBay.py b/search_eBay.py index 94a64a4..0203c70 100644 --- a/search_eBay.py +++ b/search_eBay.py @@ -36,7 +36,8 @@ def search(search_term, max_pages): while not last_result_page: result_page_added = 0 - url = 'https://www.ebay.de/sch/i.html?_from=R40&_nkw=' + search_term.replace(" ", "+") + '&_sop=10&LH_PrefLoc=1&LH_SellerType=2&LH_BIN=1&_pgn=' + str(page_counter) + url = 'https://www.ebay.de/sch/i.html?_from=R40&_nkw=' + search_term.replace(" ", "+") + '&_sacat=0&LH_TitleDesc=0&LH_BIN=1&rt=nc&LH_PrefLoc=3&_pgn=' + str(page_counter) + #url = 'https://www.ebay.de/sch/i.html?_from=R40&_nkw=' + search_term.replace(" ", "+") + '&_sop=10&LH_PrefLoc=1&LH_SellerType=2&LH_BIN=1&_pgn=' + str(page_counter) #print ("Web Page: ", url) @@ -65,6 +66,6 @@ def search(search_term, max_pages): return found_listings if __name__ == "__main__": - print(search("mainboard power pc", max_pages = 4)) + print((search("LC Power LC6450 V2.2 PC Netzteil 450W Watt", max_pages = 4)))