dcts / opensea-scraper

Scrapes nft floor prices and additional information from opensea. Used for https://nftfloorprice.info
MIT License
184 stars 73 forks source link

adding testnet #41

Closed jack75015 closed 2 years ago

jack75015 commented 2 years ago

Hey What could be nice is adding testnet option to scrap opensea testnet website :)

dcts commented 2 years ago

Is it this one: https://testnets.opensea.io

Or are there more than 1 sotes?

jack75015 commented 2 years ago

yep this one they use Rinkeby eth network

dcts commented 2 years ago

@jack75015 is this still relevant to you? Because I tested and you can simply do this (as a "hack"):

// TESTNET
const res = await OpenseaScraper.offersByUrl("https://testnets.opensea.io/collection/cyberbrokers-v3",options)
// => this gives you testnet results

// MAINNET
const res2 = await OpenseaScraper.offers("cyberbrokers-v3",options);
// => this gives you production results (empty) 
dcts commented 2 years ago

closing as testnet scraping is already supported when using offersByUrl method.

0xMarsRover commented 2 years ago

Hi dcts,

I tried to use the same code to get results from opensea testnet, but it failed with the error message below. image

It seems that the page is not actually scrapered so that there is no "html" content for further use. Any suggestions for that?

Thanks. Kai

dcts commented 2 years ago

@kaiqiangh I could replicate the issue, the problem is the following:

I am working on a feature additionalWait where you can simply add to the options the number of milliseconds to wait before starting to scrape, which should fix the issue.

will post soon once the feature is published on npm.

0xMarsRover commented 2 years ago

Thank you very much!

dcts commented 2 years ago

new version with additionalWait just published (opensea-scraper v6.5.0)

You should be able to overcome this issue like this:

  1. upgrade to OpenseaScraper v6.5.0 (by running npm install opensea-scraper@6.5.0) EDIT: bugfix added, please update to 6.5.1 instead: npm install opensea-scraper@6.5.1.
  2. add an additionalWait of ~2-4 seconds:
    // TESTNET
    const options = {
    additionalWait: 4000, // 4 seconds should work, you can try lowering that number
    }
    const res = await OpenseaScraper.offersByUrl("https://testnets.opensea.io/collection/cyberbrokers-v3",options)
    // => this gives you testnet results

let me know if it worked :)

0xMarsRover commented 2 years ago

Hi @dcts,

Much appreciated for your quick update.

It works, but there is a minor bug.

image

the offerURL should be llike "https://testnets.opensea.io/assets/rinkeby/NftAddress/nftID".

dcts commented 2 years ago

Good catch, just fixed it! Please update to newest version:

npm install opensea-scraper@6.5.1
0xMarsRover commented 2 years ago

Thanks! It perfectly works now.

dcts commented 2 years ago

great! Closing...!