如何获得网站的一段xml代码

时间:2019-05-02 07:18:04

标签: php xml

我想从网页中提取歌词,所以我使用了strpos()substr(),但是我只想在两个标签之间获取文本。

这是我的代码:

<?php
$homepage=file_get_contents("https://www.radiojavan.com/mp3s/mp3/Sahar-Ki-Asheghet-Karde");

$inja= htmlentities($homepage);
//echo strpos(htmlentities($homepage),"lyricsFars");

echo $tt= substr($inja,strpos($inja,"lyricsFars"),strpos($inja,"correct_lyrics_container"));
?>

我希望文本首先标记<div id="lyric_correction_container">,其结果是代码:

lyricsFarsi text-center" dir="rtl"> کنارمی اما اینجا تو این خونه یکی گمت کرده<br/>کی پشت اخماته کی عاشقت شده کی عاشقت کرده<br/>کنارمی اما از عطر من ردی روی لباست نیست<br/>تصویر تو تاره پلکای من خیسه اما حواست نیست<br/><br/>خیره ام بهت اما دیگه هماهنگ نیست مسیر چشمامون<br/>دیگه ازم دوری دستامو ول کردی حتی تو عکسامون<br/>تو خودتی همش با من یا با خودت با کی بهم زدی<br/>کی عاشقت کرده دوباره تو بارون با کی قدم زدی<br/><br/>یه اتفاق بد افتاده تو قلبت دستامو ول کردی<br/>درو نمی بندم با اینکه میدونم محاله برگردی<br/>حالم بده اما دلخوش به آینده ام با اینکه روشن نیست<br/>بغل نکن منو حالا که آغوشت اندازه ی من نیست<br/><br/>خیره ام بهت اما دیگه هماهنگ نیست مسیر چشمامون<br/>دیگه ازم دوری دستامو ول کردی حتی تو عکسامون<br/>تو خودتی همش با من یا با خودت با کی بهم زدی<br/>کی عاشقت کرده دوباره تو بارون با کی قدم زدی </div> <div id="lyric_correction_container"> <div class="text-center" style=""> <a href="javascript:void(0)" id="correct_lyrics" class="button textButton light">Do these lyrics need correction?</a> </div> <div class="hide" id="correct_lyrics_container"> <div id="rj_form_container"> <div id="rj_form"> <form class="rjform" action="/mp3s/mp3/Sahar-Ki-Asheghet-Karde" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><input type="hidden" name="authenticity_token" value="JELYF0JEu/NWWvRUnHmtiC6J8gh9vEdDhQMgc7B5cAO3lQnbH6JhTwH4E2gyt7zR3YRKaoBR1ZPnb+Hw9ONB1Q==" /> <textarea name="lyric" id="lyric" placeholder="Submit your lyrics!" cols="20" rows="8"></textarea> <span class="medium secondary button large-12 medium-12 columns form_submit_button">Send</span> <div class="alert-box alert large-12 medium-12 columns form_error" style="display: none; margin-top: 10px"> </div> </form>   </div> </div> <div class="alert-box success text-center form_success" style="display: none; margin-top: 10px" id="form_success"> Thank you. </div> </div> </div> </div> </div> <div class="content" id="commentsTabNew"> <div class="commentsContainer"> <div id="fb_comments" class=""> <div class="fb-comments" data-href="http://www.radiojavan.com/mp3s/mp3/Sahar-Ki-Asheghet-Karde" data-width="100%" data-numposts="10" data-colorscheme="light"></div> </div> </div> </div> </div> </div> </div> </div> </div> </section> <script> RJ.currentMP3Url = 'mp3/mp3-256/Sahar-Ki-Asheghet-Karde'; RJ.currentMP3 = '87227'; RJ.currentMP3Type = 'mp3'; RJ.playingIndex = '0'; RJ.currentMP3Perm = 'Sahar-Ki-Asheghet-Karde'; RJ.currentAlbum = null; RJ.currentPlaylist = null; RJ.relatedMP3 = [{"next":"Sahar-Ki-Asheghet-Karde","index":0},{"next":"Sahar-Lajbaz","index":1},{"next":"Sahar-Che-Haliye","index":2},{"next":"Sahar-Ey-Jan","index":3},{"next":"Amirhossein-Eftekhari-Hale-Parishoon","index":4},{"next":"Sahar-Behtarin-Mard-(Remix)","index":5},{"next":"Arash-Esmet-Chi-Chie","index":6},{"next":"Arash-Tekoon-Bede","index":7},{"next":"Sahar-Dooset-Daram","index":8},{"next":"Sahar-Ey-Vay-Ey-Jan-(Remix)","index":9},{"next":"Morvarid-Oonam-Eshghe","index":10},{"next":"Sahar-Gharibeh","index":11},{"next":"Sasy-Yekam-Yekam-(Ft-Sahar)","index":12},{"next":"Sahar-Che-Haliye-(Remix)","index":13},{"next":"Amirhossein-Eftekhari-Ziba-Negara","index":14},{"next":"Sahar-Hess-(Remix)","index":15},{"next":"Sahar-Azadi","index":16},{"next":"Sahar-Shaame-Romantic-(Remix)","index":17},{"next":"Sahar-Barf","index":18},{"next":"Sahar-Faghat-10-Salete","index":19},{"next":"Amirhossein-Eftekhari-Ey-Yar","index":20},{"next":"Sahar-Ey-Vay","index":21},{"next":"Baran-Be-Jahanam","index":22},{"next":"Sahar-To-Nabashi","index":23},{"next":"Eddie-Attar-Morvarid-Mano-Doost-Dari","index":24},{"next":"Eddie-Attar-Hame-Midoonan","index":25},{"next":"Donya-Nemidoonam-Nemidoonam","index":26},{"next":"Baran-Adat","index":27},{"next":"Arash-Goalie-Goalie-(Ft-Nyusha-Pitbull-Blanco)","index":28},{"next":"Morvarid-Man-Ke-Midoonam","index":29},{"next":"Baran-Be-Jahanam-(Vahid-Farzaneh-Remix)","index":30}]; RJ.nextMp3Base = '/mp3s/mp3/'; RJ.nextMp3AlbumBase = '/mp3s/album/'; RJ.playerVolume = 75; setupMP3Ping(); </script> <footer> <div id="bottomNav"> <a href="/apps">Download Apps</a> <a href="/contact">Contact Us</a> <a href="/ads">Advertise</a> <a href="/booking">Booking</a> <a href="/privacy">Privacy Policy</a> <a href="/terms">Terms of Use</a> </div> <p>&copy; 2019 by <strong> Radio Javan</strong>.</p> <p> All Rights Reserved.The largest source of Persian entertainment providing the best Persian and Iranian music 24/7</p> </footer> <div id="fb-root"></div> <div id="shortcutsModal" class="reveal-modal xlarge" data-reveal> <h2 class='small-12 columns'>Keyboard Shortcuts</h2> <ul class="row"> <div class="small-12 columns"> <li> <span class="key">←</span> <span class="key_action">Seek Backward</span> </li> <li> <span class="key">Shift + ←</span> <span class="key_action">Go to Previous Track</span> </li> <li> <span class="key">Space</span> <span class="key_action">Toggle Play/Pause</span> </li> <li> <span class="key">Shift + →</span> <span class="key_action">Go to Next Track</span> </li> <li> <span class="key">→</span> <span class="key_action">Seek Forward</span> </li> </div> </ul> <ul class="row" id="second_row"> <div class="small-12 columns"> <li> <span class="key">M</span> <span class="key_action">Toggle Mute</span> </li> <li> <span class="key">Shift + L</span> <span class="key_action">Toggle Repeat Song</span> </li> <li> <span class="key">H</span> <span class="key_action">Show Help</span> </li> </div> </ul> <a class="close-reveal-modal">&#215;</a> </div> <div id="login_dialog_modal" class="reveal-modal tiny" data-reveal> <h5>You need to login to Radio Javan first.</h5> <div class="row"> <div style="twelve columns"> <span class="medium secondary button" id="modal_login_cancel_button">Cancel</span> <span class="medium secondary button" id="modal_login_login_button">Login</span> </div> </div> <a class="close-reveal-modal" id="login_dialog_modal_close">&#215;</a> </div> <div id="app_overlay"> <div class="container"> <div class="section"> <a style="color: white" class="close_link">&#215;</a> </div> <div class="section"> <div style="padding-bottom: 20px"> <img src="https://assets.rj-a1.com/static/mp3/sahar-ki-asheghet-karde/e9e17c16e974a23.jpg" class="cover"/> </div> Play this song with the Radio Javan app.</a> </div> <div class="section"> <div> <a href="https://itunes.apple.com/app/apple-store/id286225933?mt=8" class="app_black button" style="color: #fff; text-decoration: none">GET RADIO JAVAN APP</a> </div> <div style="margin-top: 10px"> <a href="radiojavan://mp3/87227/" class="app_red button" style="color: #fff; text-decoration: none">OPEN RADIO JAVAN</a> </div> </div> </div> </div> <script> $('#app_overlay .close_link').on('click', function() { window.location.href = 'https://www.radiojavan.com/mp3s/mp3/Sahar-Ki-Asheghet-Karde'; }); </script> <script> $(document).foundation(); </script> </body> </html>

0 个答案:

没有答案