Skip to content

Instantly share code, notes, and snippets.

import pandas as pd
import json
import numpy as np
df = pd.read_excel('Analyzer Test Task.xlsx')
# Convert NaN values to None
df = df.replace("", None)
df = df.replace(r'^\s*$', "", regex=True)
def _request_product(asin):
print(f" asin {asin}")
retry_count = 0
max_retries = 4
while retry_count < max_retries:
try:
products = api.query(asin, domain='GB', rating=1, buybox=1, update=0)
break # If the request is successful, break out of the loop
except ReadTimeout:
{
"asin": "B0BF9NT29Q",
"brand": "Farming Simulator",
"color": null,
"country_origin": null,
"currency": "£",
"customer_reviews": 92.0,
"description": "The most extensive farming sim to date! With the Platinum Edition of Farming Simulator 22, you start your farming venture in one of four distinctive European and American environments to take on agriculture, forestry and animal husbandry. At your disposal: More than 500 authentic machines and tools by over 100 renowned agricultural manufacturers from all over the world. With Farming Simulator 22, various new gameplay mechanics are introduced: Seasonal cycles challenge you to plan ahead and adapt to changing weather conditions. New crops like grapes and olives require you to carefully work in narrow spaces with specialized machines, and various production chains allow you to build an agricultural empire. Platinum Expansion included - get even more content! Included in the Platinum Edition, apart from the already massive base game, is
{
"data": {
"asin": "B0BF9NT29Q",
"brand": "Farming Simulator",
"color": null,
"country_origin": null,
"currency": "£",
"customer_reviews": 92.0,
"description": "The most extensive farming sim to date! With the Platinum Edition of Farming Simulator 22, you start your farming venture in one of four distinctive European and American environments to take on agriculture, forestry and animal husbandry. At your disposal: More than 500 authentic machines and tools by over 100 renowned agricultural manufacturers from all over the world. With Farming Simulator 22, various new gameplay mechanics are introduced: Seasonal cycles challenge you to plan ahead and adapt to changing weather conditions. New crops like grapes and olives require you to carefully work in narrow spaces with specialized machines, and various production chains allow you to build an agricultural empire. Platinum Expansion included - get even more content! Included in the Platinum Edition, ap
{
"href": "https://api.ebay.com/buy/browse/v1/item_summary/search?q=711719989998&limit=50&filter=conditionIds%3A%7B1000%7D%2CbuyingOptions%3A%7BFIXED_PRICE%7D%2CitemLocationCountry%3AGB%2CdeliveryCountry%3AGB%2CsellerAccountTypes%3A%7BBUSINESS%7D&offset=0",
"total": 5,
"limit": 50,
"offset": 0,
"itemSummaries": [
{
"itemId": "v1|226239997965|0",
"title": "God of War III: Remastered (Playstation Hits) (PS4) (New)",
"leafCategoryIds": [
{
"href": "https://api.ebay.com/buy/browse/v1/item_summary/search?q=0696580589792&limit=50&filter=conditionIds%3A%7B1000%7D%2CbuyingOptions%3A%7BFIXED_PRICE%7D%2CitemLocationCountry%3AGB%2CdeliveryCountry%3AGB%2CsellerAccountTypes%3A%7BBUSINESS%7D%2CmaxDeliveryCost%3A0&offset=0",
"total": 35,
"limit": 50,
"offset": 0,
"itemSummaries": [
{
"itemId": "v1|166031549255|0",
"title": "Korg - EXP2 Foot Controller for MIDI Keyboard",
"leafCategoryIds": [
{
"error": false,
"status": 200,
"response": {
"href": "https://api.ebay.com/buy/browse/v1/item_summary/search?q=6943478034204&limit=50&filter=conditionIds%3A%7B1000%7D%2CbuyingOptions%3A%7BFIXED_PRICE%7D%2CitemLocationCountry%3AGB%2CdeliveryCountry%3AGB%2CsellerAccountTypes%3A%7BBUSINESS%7D&offset=0",
"total": 3,
"limit": 50,
"offset": 0,
"itemSummaries": [
{
def run(d, meta_keys_list: list, alternative_filter_keys: list = None):
db_connector.connect()
try:
# Build filter conditions based on provided keys
conditions = False
if alternative_filter_keys:
conditions = [getattr(Product, key) == d[key] for key in alternative_filter_keys if key in d]
if conditions:
product_row = db_connector.session.query(Product).filter(and_(*conditions)).first()
products_query = db_connector.session.query(
DataFeedEbay.legacyitemid,
DataFeedEbay.categoryid.label('categoryid'),
DataFeedEbay.id.label('datafeed_id'),
Product.id.label('product_id'),
Product.description,
Product.in_stock_status,
Product.product_slug_new
).join(
Product,
[
{
"itemId": "v1|325681931382|0",
"title": "Greak: Memories of Azur Sony PlayStation 5 PS5 Platform Game NEW & SEALED",
"leafCategoryIds": [
"139973"
],
"categories": [
{
"categoryId": "139973",