Доброе время суток граждане кодыры! подскажите как можно спарсить данные с странички dex.guru/token/0x965f527d9159dce6288a2219db51fc6eef120dd1-bsc интересуют: Trading Volume Liquidity текущая цена загвоздка в том что контент собирается при помощи JS и спарсить данные через PHP не удается без манипуляций с JS Готов на пивас выставиться за совет) Ну или преобрести готовое решение. Вот что парситься при помощи ПХП: HTML: !doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <script src="/datafeeds/udf/dist/polyfills.js"></script><script src="/datafeeds/udf/dist/bundle.js"></script> <meta name="viewport" content="width=device-width,initial-scale=1" /> <title>DexGuru</title> <link rel="preconnect" crossorigin href="https://t.co" /> <link rel="preconnect" crossorigin href="https://analytics.twitter.com" /> <link rel="preconnect" crossorigin href="https://stats.g.doubleclick.net" /> <link rel="preconnect" crossorigin href="https://www.googletagmanager.com" /> <link rel="preconnect" crossorigin href="https://static.ads-twitter.com" /> <link rel="preconnect" crossorigin href="https://www.google-analytics.com" /> <link rel="preconnect" crossorigin href="https://fonts.gstatic.com" /> <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" /> <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" /> <link rel="icon" type="image/png" sizes="194x194" href="/favicon-194x194.png" /> <link rel="icon" type="image/png" sizes="192x192" href="/android-chrome-192x192.png" /> <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" /> <link rel="manifest" href="/manifest.json" /> <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#9488f0" /> <meta name="apple-mobile-web-app-title" content="dexGuru" /> <meta name="application-name" content="DexGuru" /> <meta name="msapplication-TileColor" content="#0b0f14" /> <meta name="msapplication-TileImage" content="/mstile-144x144.png" /> <meta name="theme-color" content="#ffffff" /> <meta name="description" content="Guru knows a thing or two about what is going on at AMM DEXs" /> <meta name="twitter:card" content="summary_large_image" /> <meta name="twitter:site" content="https://dex.guru" /> <meta name="twitter:creator" content="@dexGuru" /> <meta name="twitter:title" content="DexGuru - DeFi Trading Terminal" /> <meta name="twitter:description" content="Guru knows a thing or two about what is going on at AMM DEXs" /> <meta name="twitter:image" content="https://dex.guru/og.png" /> <meta property="og:title" content="DexGuru - DeFi Trading Terminal" /> <meta property="og:type" content="website" /> <meta property="og:url" content="https://dex.guru" /> <meta property="og:description" content="Guru knows a thing or two about what is going on at AMM DEXs" /> <meta property="og:image" content="https://dex.guru/og.png" /> <meta property="og:image:width" content="1200" /> <meta property="og:image:height" content="630" /> <link href="https://fonts.googleapis.com/css?family=Kanit:300,400,500,600&display=swap" rel="stylesheet" /> <link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600,700&display=swap" rel="stylesheet" /> <link href="/static/css/2.d98a48d3.chunk.css" rel="stylesheet"> <link href="/static/css/main.2047f89f.chunk.css" rel="stylesheet"> </head> <body> <noscript>You need to enable JavaScript to run this app.</noscript> <div id="root"></div> <script>!function(e){function r(r){for(var n,a,i=r[0],c=r[1],l=r[2],s=0,p=[];s<i.length;s++)a=i[s],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&p.push(o[a][0]),o[a]=0;for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(e[n]=c[n]);for(f&&f(r);p.length;)p.shift()();return u.push.apply(u,l||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++){var c=t[i];0!==o[c]&&(n=!1)}n&&(u.splice(r--,1),e=a(a.s=t[0]))}return e}var n={},o={1:0},u=[];function a(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.e=function(e){var r=[],t=o[e];if(0!==t)if(t)r.push(t[2]);else{var n=new Promise((function(r,n){t=o[e]=[r,n]}));r.push(t[2]=n);var u,i=document.createElement("script");i.charset="utf-8",i.timeout=120,a.nc&&i.setAttribute("nonce",a.nc),i.src=function(e){return a.p+"static/js/"+({}[e]||e)+"."+{3:"c79bd09e",4:"78aa4e4e"}[e]+".chunk.js"}(e);var c=new Error;u=function(r){i.onerror=i.onload=null,clearTimeout(l);var t=o[e];if(0!==t){if(t){var n=r&&("load"===r.type?"missing":r.type),u=r&&r.target&&r.target.src;c.message="Loading chunk "+e+" failed.\n("+n+": "+u+")",c.name="ChunkLoadError",c.type=n,c.request=u,t[1](c)}o[e]=void 0}};var l=setTimeout((function(){u({type:"timeout",target:i})}),12e4);i.onerror=i.onload=u,document.head.appendChild(i)}return Promise.all(r)},a.m=e,a.c=n,a.d=function(e,r,t){a.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,r){if(1&r&&(e=a(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(a.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)a.d(t,n,function(r){return e[r]}.bind(null,n));return t},a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,"a",r),r},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.p="/",a.oe=function(e){throw console.error(e),e};var i=this.webpackJsonpdexguru=this.webpackJsonpdexguru||[],c=i.push.bind(i);i.push=r,i=i.slice();for(var l=0;l<i.length;l++)r(i[l]);var f=c;t()}([])</script><script src="/static/js/2.c8cdd201.chunk.js"></script><script src="/static/js/main.6f029c97.chunk.js"></script><script defer src="https://static.cloudflareinsights.com/beacon.min.js" data-cf-beacon='{"rayId":"6576cd9eba3a7b3f","token":"6847cfeca4bc433296b7e807aa73b40e","version":"2021.5.2","si":10}'></script> </body> </html> сам парсер PHP: <?phpfunction get_web_page( $url ){ $options = array( CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => false, // don't return headers CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => "", // handle all encodings CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0 ", CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response CURLOPT_SSL_VERIFYPEER => false, CURLOPT_MAXREDIRS => 10, // stop after 10 redirects ); $ch = curl_init( $url ); curl_setopt_array( $ch, $options ); $content = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch ); curl_close( $ch ); $header['errno'] = $err; $header['errmsg'] = $errmsg; $header['content'] = $content; return $header;}var_dump(get_web_page('https://dex.guru/token/0x965f527d9159dce6288a2219db51fc6eef120dd1-bsc'));
PHP: $res = get_web_page('https://api.dex.guru/v1/tokens/0x965f527d9159dce6288a2219db51fc6eef120dd1?network=bsc');print_r(json_decode($res['content'], true)); Code: Array ( [id] => 0x965f527d9159dce6288a2219db51fc6eef120dd1-bsc [symbol] => BSW [name] => Biswap [description] => Biswap/BSW [txns24h] => 7131 [txns24hChange] => -0.020216378425334 [verified] => [decimals] => 18 [volume24h] => 2061853.1464347 [volume24hUSD] => 1469500.9945041 [volume24hETH] => 33130.579085328 [volumeChange24h] => -0.004886741414331 [liquidityUSD] => 994288.00710697 [liquidityETH] => 22416.682653669 [liquidityChange24h] => -0.074595798849695 [priceUSD] => 0.71270885467529 [priceETH] => 0.01606835052371 [priceChange24h] => -0.35722474356395 [timestamp] => 1622396806 [blockNumber] => 7865933 [AMM] => pancakeswap [network] => bsc ) Будет достаточно, если рассчитаемся по старым кейсам