www.webdeveloper.com
Results 1 to 5 of 5

Thread: Get text between specific span class store in database

  1. #1
    Join Date
    Sep 2013
    Posts
    221

    Get text between specific span class store in database

    I have to get text between specific span class store in database.
    I have tried it using DOM() , below is the code:
    <?php

    ini_set( "display_errors", 0); //warning not to display
    $homepage = file_get_contents('http://justdial.com/Mumbai/Restaurants/ct-304085');

    $xml = '<span class="jcn">Details i want to get</span>';
    $dom = new DOMDocument;
    $dom->loadHTML($homepage);
    $spans = $dom->getElementsByTagName('span');


    echo $span;

    foreach ($spans as $span) {

    echo strip_tags($span->nodeValue), PHP_EOL;
    }

    ?>

    I have to get all the span class="jcn" values inserted into my database. But not geting the proper output.
    Please help me out of this.
    Thanx in advance.
    strad solutionswww.stradsolutions.com

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,326
    PHP Code:
    foreach ($spans as $span) {
        if(
    $span->getAttribute('class') == 'jcn') {
            echo 
    trim(strip_tags($span->nodeValue)), PHP_EOL;
        }

    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Sep 2013
    Posts
    221
    Thank-you for the code it was helpfull but now am looking for the span class="jcn" values of the same url to be inserted in my database.
    strad solutionswww.stradsolutions.com

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,326
    Quote Originally Posted by priyankagound View Post
    Thank-you for the code it was helpfull but now am looking for the span class="jcn" values of the same url to be inserted in my database.
    Afraid that doesn't really mean anything to me.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  5. #5
    Join Date
    Sep 2013
    Posts
    221
    I fixed my problem. Got what was looking for.
    strad solutionswww.stradsolutions.com

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles