Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please...cant scrape color name and size name from amazon.es #120

Open
mkudev opened this issue Aug 20, 2023 · 0 comments
Open

Please...cant scrape color name and size name from amazon.es #120

mkudev opened this issue Aug 20, 2023 · 0 comments

Comments

@mkudev
Copy link

mkudev commented Aug 20, 2023

I created it, but not working, rest of script work fine, I need scrap asin details of color and size names, text plain to easy csv import to woocommece. I hope you help bro.

const fs = require('fs').promises;
const amazonScraper = require('amazon-buddy');
const createCsvWriter = require('csv-writer').createObjectCsvWriter;

(async () => {
try {
const asinList = await fs.readFile('asin-list.txt', 'utf-8');
const asinArray = asinList.trim().split('\n');

    const productsData = await amazonScraper.asin({
        asin: asinArray,
        country: 'ES',
        category: 'moda',
        limit: 13,
        filetype: 'csv'
    });

    for (const product of productsData) {
        product.variation_color_name = ''; // Agrega esto para evitar el error en caso de que no se encuentre la propiedad
        const sizeOptions = $('#native_dropdown_selected_size_name option[value!="0,B01M1C6RFY"]').map((index, element) => {
            const value = $(element).attr('value');
            const size = $(element).text().trim();
            return { value, size };
        }).get();

        product.size_options = sizeOptions;
    }

    const csvWriter = createCsvWriter({
        path: 'output.csv',
        header: [
            { id: 'asin', title: 'ASIN' },
            { id: 'url', title: 'URL' },
            { id: 'product', title: 'Producto' },
            { id: 'variation_color_name', title: 'Nombre de Color' },
            // ... (otros encabezados)
            { id: 'size_options', title: 'Opciones de Tamaño' },
            { id: 'variants', title: 'Variantes' },
            // ... (otros encabezados)
        ]
    });

    await csvWriter.writeRecords(productsData);

    console.log('Archivo CSV ha sido creado exitosamente.');
} catch (fileError) {
    console.log('Error al leer asin-list.txt:', fileError);
}

})();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant