How to scrape a website from opensea using node js

563 views Asked by At

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)

});
1

There are 1 answers

2
Moetaz Brayek On BEST ANSWER
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