-1

I am trying to extract div class .sc-8a1b6610-0.TdEDc value from URL: https://opensea.io/rankings

Basically select at random top nft collection name.

When I load the code in browser I get a blank page how can I fix the code?

$(document).ready(function() {
  $.ajax({
    url: 'https://opensea.io/rankings',
    success: function(data) {
      $('#myDiv').html($(data).find('.sc-8a1b6610-0.TdEDc'));
    }
  });
});
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<div id="myDiv"></div>
mplungjan
  • 169,008
  • 28
  • 173
  • 236
  • 1
    I added myDiv in the snippet I made you. You get CORS errors. The target does not allow you to do what you are trying to do. Look in the console and network tab to see `Cross-Origin-Opener-Policy: same-origin ` – mplungjan Aug 15 '23 at 13:34
  • That page also appears to have AJAX loading, so it can't just get the top item in the list since it will not have loaded yet when you make the request – Chris Barr Aug 15 '23 at 13:35
  • Always check the Web Inspector. Trying to AJAX a webpage which you do not control will usually have CORS issues to prevent you from harvesting their data. You will need to using their API if they have one. – Jordan Aug 15 '23 at 13:35

0 Answers0