Search code examples
node.jsrequestopensea

How to scrape a website from opensea using node js


I'm failing at trying to scrape a collection of polygon NFTs from Opensea. Could someone please provide an example that prints the html returned in console? I tried the code below:

const https = require("https");

https.get("https://opensea.io/collection/orathai", response => {
        console.log(response)

});

Solution

  • const axios = require('axios').default;
    
    axios.get('https://api.opensea.io/api/v1/collection/orathai/?format=json')
        .then(resp => {
            console.log(resp.data);
        })
        .catch(err => {
            // Handle Error Here
            console.error(err);
        });
    

    don't forget : npm i axios

    Refrence :

    opensea api docs

    Axios