wafa Posted March 5, 2015 Share Posted March 5, 2015 Hello out there! Firstly thanks to help people coding. I'm trying to extract information(name and speciality) from this link: http://www.sante-dz.com/carteinfomed.php?spe=39&nom=&rig=Alger&pubspace=i&firsturl=L21lZGVjaW5zLnBocD90aXQ9bCZtYXhSb3dzX21lZGVjaW5zPTEwMCZzcGU9MzkmcmlnPUFsZ2Vy 1- when I try to reach the text written between <span> here <span>, I recuperate all the texts written in the same tag but only the desired information couldn't be reached, 2- I recuperate a link gathering information of every doctor,, but can't also extract just the linkw which is contained in a string here is my simple code: <!DOCTYPE html> <html lang="fr"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Parser...</title> <link rel="stylesheet" type="text/css" href="../css/style.css" /> </head> <body> <div class="wrapper"> <h1>La base des medecins algeriens </h1> <?php require_once 'simple_html_dom.php'; //Create an object simple_html_dom() $html = new simple_html_dom(); //Create an object simple_html_dom() $htmll = new simple_html_dom(); // load the html file $html->load_file('http://www.sante-dz.com/medecins.php?tit=l&maxRows_medecins=100&spe=39&rig=Alger'); //All links of doctors information foreach($html->find( 'td[class=txtgray9all] div') as $info) echo $info->onclick. '<br>'; // the string recuperated should be parsed to extract the desired // $parsedlink= // echo $htmll->load_file('http://www.sante-dz.com/carteinfomed.php?'.$parsedlink); $htmll->load_file('http://www.sante-dz.com/carteinfomed.php?spe=39&nom=&rig=Alger&pubspace=i&firsturl=L21lZGVjaW5zLnBocD90aXQ9bCZtYXhSb3dzX21lZGVjaW5zPTEwMCZzcGU9MzkmcmlnPUFsZ2Vy'); foreach($htmll->find('span.txtblue92ball') as $e) echo $e->outertext . '<br>';// i don't get any result ?> </div> </body> </html> Quote Link to comment Share on other sites More sharing options...
nik_jain Posted April 26, 2015 Share Posted April 26, 2015 The perfect way of parsing HTML in PHP is via the library 'Querypath' its a wrapper around DOM , so no regex.Also the syntax is very jQuery like.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.