Jump to content

Search the Community

Showing results for tags 'simple_html_dom'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (Dreamweaver, Zend, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

Found 3 results

  1. I want to scrape a website content. here is the example html source code of that site. <div class="entry-content"> <h2>hi tags?</h2> <ul> <li>some text</li> <li>sometext</li> <li>sometext</li> <li>sometext</li> </ul> <h2>hi tags2 ?</h2> <ul> <li>some text</li> <li>sometext</li> <li>To ometext</li> <li>Theometext</li> </ul> </div> I want to extract data of <li> tags from first <ul> html code. Here I've tried. include('../simple_html_dom.php'); // get DOM from URL or file //$html = check above html code $articles = $html->find('div[class="entry-content"]') ? $html->find('div[class="entry-content"]') : []; foreach($articles as $article) { $items = $article->find('ul',0) ? $article->find('ul',0) : false; if($items !==false){ $lis = $item->find('li') ? $item->find('li') : []; foreach($lis as $b){ $mcpcons .= $b->plaintext; } } } Help me by giving the correct info how can I do that?
  2. 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>
  3. Ok I am a complete noob!!! I have done many searches and believe that I have done quite well some what piecing together my script. So I use a forum which has a gear swap section for buying used goods problem is that if you try to search for specific goods then it searches the entire forum. So I found the simple_html_dom class that has the file_get_html method and was able to select only the titles of the listings. I had no problem displaying these listings and then populating a db. Now I want to use if and else-if statements along with regex to grab titles with specific keywords and put them in a corresponding column in my db which I have been unsuccessful at. I'd also like to eventually make my db searchable on my site I'm sure my code could be cleaned up in about every area so if anybody whats to chime in on any part of my code please feel free. It will be much appreciated I have put in many hours and I would like to know that building someone on the right footing lol. you can view my webpage at http://php-ryanlitwiller.rhcloud.com/ - in my page the titles still have their hyperlink but they try to navigate my server...any ideas of how to make them reach the original site? <?php // Open a MySQL connection $link = mysql_connect('', 'xxxxxxxxxx', 'xxxxxxxxxx'); if(!$link) { die('Connection failed: ' . mysql_error()); } // Select the database to work with $db = mysql_select_db('test'); if(!$db) { die('Selected database unavailable: ' . mysql_error()); } // import simple_html_dom.php to give me various methods for website selection and scraping include('simple_html_dom.php'); // get DOM from BPL URL $html = file_get_html('http://www.backpackinglight.com/cgi-bin/backpackinglight/forums/display_forum.html?forum=19'); // find all td tags with class=forum_listing foreach($html->find('td.forum_listing') as $tdTagExt) //grab just a tags foreach($tdTagExt->find('a')as $aTagExt){ //print selected outertext from previous selectors $refinedTitle = $tdTagExt->outertext; //display nobull listing of goods echo $refinedTitle . '<br>'; //find tent goods using regex to check for the word tent if(preg_match_all('/tent/', $refinedTitle)){ // add matches to corresponding sql coulom $sql = "insert into `bp` (`tent`) values ('$refinedTitle')"; $result = mysql_query($sql); //find sleeping bags using regex to check for the word bag } else if(preg_match_all('/bag/', $refinedTitle)){ $sql1 = "insert into `bp` (`bag`) values ('$refinedTitle')"; $result1 = mysql_query($sql1); //find boots using regex to check for the word boot or shoes } else if(preg_match_all('/boot|shoes/', $aTagExt->innertext)){ $sql2 = "insert into `bp` (`boot`) values ('$aTagExt->innertext')"; $result2 = mysql_query($sql2); //find clothing goods using regex to check for any of the words shirt|pants|parka|shorts|jacket } else if(preg_match_all('/shirt|pants|parka|shorts|jacket/', $aTagExt->innertext)){ $sql3 = "insert into `bp` (`clothing`) values ('$aTagExt->innertext')"; $result3 = mysql_query($sql3); } else { // Create and execute a MySQL query $sql4 = "insert into `bp` (`ahref`) values ('$aTagExt->innertext')"; $result4 = mysql_query($sql4); } } // Close the connection mysql_close($link); ?>
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.