Gautam
Gautam

Reputation: 13

how to scrape the external url using php simple html dom parser

<div id="lyrics">
  <img />
  <span id="line_31" class="line line-s">En medio de este tropico mortal</span
  <br>
  <span id="line_32" class="line line-s">Roots and creation, come again!</span>
  <br> 
  <span id="line_33" class="line line-s">So mi guardian, mi guardian mi lift up di plan</span>
  <span id="line_34" class="line line-s">Now everybody a go' do dis one</span>
  <span id="line_35" class="line line-s">Like in down di Caribbean</span>
  <span id="line_36" class="line line-s">San Andrés, Providence Island</span>
  <br>
</div>

Here I have a div, inside div there is multiple span and br tag between span. I want to scrape the span text and br tag as it is. so how can i scrape with php simple dom parser.

thanks for any help.

Upvotes: 1

Views: 1543

Answers (1)

Andrew Briggs
Andrew Briggs

Reputation: 1349

Let's say the html file you have above is called "index.html".

$html = file_get_html("index.html");
$element = $html->find('div#lyrics');
$result = $element->innertext;

You want to consult the manual: http://simplehtmldom.sourceforge.net/

Upvotes: 2

Related Questions