0

I want to get all div content of the site

I want to get this div

<div class="user_name"/>

there are so many user_name as class name of the divs in the page but I want to get all div content

I have this code which I got it here Get DIV content from external Website

$url = 'http://www.myexternalsite.com/user/1';
$content = file_get_contents($url);
$first_step = explode( '<div class="user_name"/>' , $content );
$second_step = explode("</div>" , $first_step[1] );

echo $second_step[0];
Community
  • 1
  • 1
Marverick M.
  • 124
  • 1
  • 15

1 Answers1

0

Try PHP Simple HTML DOM Parser

Manh Nguyen
  • 930
  • 5
  • 12