Skip to content

Instantly share code, notes, and snippets.

@saahityaedams
Created January 23, 2025 15:53
Show Gist options
  • Select an option

  • Save saahityaedams/ee04c2f491a06977487bf3092a3d0bd7 to your computer and use it in GitHub Desktop.

Select an option

Save saahityaedams/ee04c2f491a06977487bf3092a3d0bd7 to your computer and use it in GitHub Desktop.
download amazon item price history
  1. Goto pricehistory.app and enter the url of item you want the price history of.
  2. Open the browser console and run the following function.
function downloadPriceDataIntoCSV() {
  
    price_series = chart.data.datasets.filter(item => item.label == "Prices")[0].data
    
    // Create CSV header
    const headers = ['price,datetime\n'];
    
    // Convert data to CSV rows
    const csvRows = price_series.map(item => 
        `${item.y},${item.x}`
    );

    // Combine headers and rows
    const csvContent = headers.concat(csvRows).join('\n');

    // Create blob and download link
    const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
    const link = document.createElement('a');
    
    // Create download URL
    const url = window.URL.createObjectURL(blob);
    link.setAttribute('href', url);
    link.setAttribute('download', 'data.csv');
    
    // Append link, trigger download, and remove link
    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link);
}

// Usage
downloadPriceDataIntoCSV();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment