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

Extra tokenId in a different manner #14

Closed robertistok closed 3 years ago

robertistok commented 3 years ago

Instead of getting it from the name, get from the href element of the card.

In case of the The Sandbox example, the tokenId was not present in the card in the same way as in for the Coolcats one.

dcts commented 3 years ago

Also just thought of adding the whole asset URL to the results, would be really usefull if you want to notify a user with the direct link where to buy that asset!

dcts commented 3 years ago

thanks @robertistok ! 💯

robertistok commented 3 years ago

That's a great idea! Could be an easy addition. On this note, I also thought it would be useful to return the total number of items that are available for sale. The best would be to use this endpoint for it. Maybe return an object with the following structure:

return {
  offers: IOffer[],
  stats: { totalForSale: 1856 }
}

This would have the benefit of making it flexible, so we could add more stuff to it later. Although it would not make the script backward compatible

dcts commented 3 years ago

Yeah makes sense to me, if you want you can submit a PR or I can do it some time later. This should do the trick:

const resultsText = document.querySelector(".AssetSearchView--results-count").innerText;
const totalForSale = Number(restultsText.split(" ")[0]);
dcts commented 3 years ago

concerning assetUrl I did add it already in the last update 3.1.0 (offerUrl) 1721268dbe94220f5dc45e84d866ded3f3cbe228