Solved

php, cURL, extract iframe

Posted on 2012-03-29
13
1,874 Views
Last Modified: 2012-03-30
Hi,
I have this variable which has inint some content from a cURL query, i need to be able to extract the iframe out of it.. how would i do that?

$bookurl = 'http://www.goodreads.com/book/isbn?isbn=184719088X&key='.$GoodReads_API_KEY;
// specific url to request a book, this can be build dynamically by inserting different methods where it says book_url and such. See the API docs to see more about how the different URLs should be look

$ch = curl_init(); // Initialize curl  handle
curl_setopt($ch, CURLOPT_TIMEOUT, 5); // 5 second timeout
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return the result on success, rather than just TRUE
curl_setopt($ch, CURLOPT_URL, $bookurl); // Set the url for curl to request to

$response = curl_exec($ch); // makes the request and gets the response

echo '<pre>';
print_r($response);
echo '</pre>'

Open in new window


the result - market with '------' where iframe is
  
    true
      
    
  
  
  53732
  
  
  
  
  http://www.goodreads.com/images/nocover-111x148.jpg
  http://www.goodreads.com/images/nocover-60x80.jpg
  1990
  9
  1
  Ace/Berkley Books
  eng
  false
  
  
  234225
  137
  3634639
  book
  
  
  
  1965
  Dune
  5:79751|4:52480|3:32518|2:11728|1:9303|total:185780
  186613
  742519
  252551
  4399


  
  
  
  
  
  
  
  
  
  
    


    
    58
        
    
    
    
    3.88
    293472
    7134
  
  
    
    
      
  #goodreads-widget {
    font-family: georgia, serif;
    padding: 18px 0;
    width:565px;
  }
  #goodreads-widget h1 {
    font-weight:normal;
    font-size: 16px;
    border-bottom: 1px solid #BBB596;
    margin-bottom: 0;
  }
  #goodreads-widget a {
    text-decoration: none;
    color:#660;
  }
  iframe{
    background-color: #fff;
  }
  #goodreads-widget a:hover { text-decoration: underline; }
  #goodreads-widget a:active {
    color:#660;
  }
  #gr_footer {
    width: 100%;
    border-top: 1px solid #BBB596;
    text-align: right;
  }
  #goodreads-widget .gr_branding{
    color: #382110;
    font-size: 11px;
    text-decoration: none;
    font-family: verdana, arial, helvetica, sans-serif;
  }


  
Dune Reviews

----------------------------------------there is an iframe here which encloses the reviews - i need to have this iframe and nothing else.
  
  

    Reviews from Goodreads.com
  



      ]]>
    
  
  
          
          
          
          
          
          
          
          
          
          
      
  
    
  8
  
  http://www.goodreads.com/book_link/follow/8?book_id=53732

  1027
  
  http://www.goodreads.com/book_link/follow/1027?book_id=53732

  9
  
  http://www.goodreads.com/book_link/follow/9?book_id=53732

  4
  
  http://www.goodreads.com/book_link/follow/4?book_id=53732

  2
  
  http://www.goodreads.com/book_link/follow/2?book_id=53732

  10
  
  http://www.goodreads.com/book_link/follow/10?book_id=53732

  5
  
  http://www.goodreads.com/book_link/follow/5?book_id=53732

  2102
  
  http://www.goodreads.com/book_link/follow/2102?book_id=53732

  1602
  
  http://www.goodreads.com/book_link/follow/1602?book_id=53732

  107
  
  http://www.goodreads.com/book_link/follow/107?book_id=53732

  7
  
  http://www.goodreads.com/book_link/follow/7?book_id=53732

  1
  
  http://www.goodreads.com/book_link/follow/1?book_id=53732

  
  
    
166801
1

45935


two-volume omnibus series.
    
    See also:
    * Prelude to Dune
    * Legends of Dune
]]>




17
8
true

Open in new window


what would be the best way todo this?

thanks in advance guys
0
Comment
Question by:MK15
  • 7
  • 5
13 Comments
 
LVL 7

Expert Comment

by:designatedinitializer
ID: 37785487
you need a parser.
I guess you could do it with a xml parser.
Can you post the complete contents of the result, including <iframe>?
0
 

Author Comment

by:MK15
ID: 37785940
hi,
I tried it with an xml parser but i simply can't get to the widget

the iframe is not visible displaying whilst pasting the contents, it simply gets cut out.  the iframe contains the community reviews from this website
http://www.goodreads.com/book/show/2102050.PHP_Web_2_0_Mashup_Projects

the xml results

SimpleXMLElement Object
(
    [Request] => SimpleXMLElement Object
        (
            [authentication] => true
            [key] => SimpleXMLElement Object
                (
                )

            [method] => SimpleXMLElement Object
                (
                )

        )

    [book] => SimpleXMLElement Object
        (
            [id] => 2102050
            [title] => SimpleXMLElement Object
                (
                )

            [isbn] => SimpleXMLElement Object
                (
                )

            [isbn13] => SimpleXMLElement Object
                (
                )

            [asin] => SimpleXMLElement Object
                (
                )

            [image_url] => http://www.goodreads.com/images/nocover-111x148.jpg
            [small_image_url] => http://www.goodreads.com/images/nocover-60x80.jpg
            [publication_year] => SimpleXMLElement Object
                (
                )

            [publication_month] => SimpleXMLElement Object
                (
                )

            [publication_day] => SimpleXMLElement Object
                (
                )

            [publisher] => SimpleXMLElement Object
                (
                )

            [language_code] => SimpleXMLElement Object
                (
                )

            [is_ebook] => false
            [description] => SimpleXMLElement Object
                (
                )

            [work] => SimpleXMLElement Object
                (
                    [best_book_id] => 2102050
                    [books_count] => 1
                    [id] => 2107414
                    [media_type] => SimpleXMLElement Object
                        (
                            [@attributes] => Array
                                (
                                    [nil] => true
                                )

                        )

                    [original_language_id] => SimpleXMLElement Object
                        (
                            [@attributes] => Array
                                (
                                    [nil] => true
                                    [type] => integer
                                )

                        )

                    [original_publication_day] => 22
                    [original_publication_month] => 9
                    [original_publication_year] => 2007
                    [original_title] => PHP Web 2.0 Mashup Projects: Practical PHP Mashups with Google Maps, Flickr, Amazon, YouTube, MSN Search, Yahoo!
                    [rating_dist] => total:10|5:1|4:5|3:3|2:1|1:0|
                    [ratings_count] => 10
                    [ratings_sum] => 36
                    [reviews_count] => 20
                    [text_reviews_count] => 1
                )

            [average_rating] => SimpleXMLElement Object
                (
                )

            [num_pages] => SimpleXMLElement Object
                (
                )

            [format] => SimpleXMLElement Object
                (
                )

            [edition_information] => SimpleXMLElement Object
                (
                )

            [ratings_count] => SimpleXMLElement Object
                (
                )

            [text_reviews_count] => SimpleXMLElement Object
                (
                )

            [url] => SimpleXMLElement Object
                (
                )

            [link] => SimpleXMLElement Object
                (
                )

            [authors] => SimpleXMLElement Object
                (
                    [author] => SimpleXMLElement Object
                        (
                            [id] => 804036
                            [name] => SimpleXMLElement Object
                                (
                                )

                            [image_url] => SimpleXMLElement Object
                                (
                                )

                            [small_image_url] => SimpleXMLElement Object
                                (
                                )

                            [link] => SimpleXMLElement Object
                                (
                                )

                            [average_rating] => 3.60
                            [ratings_count] => 10
                            [text_reviews_count] => 1
                        )

                )

            [reviews_widget] => SimpleXMLElement Object
                (
                )

            [popular_shelves] => SimpleXMLElement Object
                (
                    [shelf] => Array
                        (
                            [0] => SimpleXMLElement Object
                                (
                                    [@attributes] => Array
                                        (
                                            [name] => to-read
                                            [count] => 6
                                        )

                                )

                            [1] => SimpleXMLElement Object
                                (
                                    [@attributes] => Array
                                        (
                                            [name] => computers
                                            [count] => 1
                                        )

                                )

                            [2] => SimpleXMLElement Object
                                (
                                    [@attributes] => Array
                                        (
                                            [name] => it
                                            [count] => 1
                                        )

                                )

                            [3] => SimpleXMLElement Object
                                (
                                    [@attributes] => Array
                                        (
                                            [name] => technical
                                            [count] => 1
                                        )

                                )

                            [4] => SimpleXMLElement Object
                                (
                                    [@attributes] => Array
                                        (
                                            [name] => techbooks
                                            [count] => 1
                                        )

                                )

                            [5] => SimpleXMLElement Object
                                (
                                    [@attributes] => Array
                                        (
                                            [name] => tech
                                            [count] => 1
                                        )

                                )

                            [6] => SimpleXMLElement Object
                                (
                                    [@attributes] => Array
                                        (
                                            [name] => ebook
                                            [count] => 1
                                        )

                                )

                            [7] => SimpleXMLElement Object
                                (
                                    [@attributes] => Array
                                        (
                                            [name] => currently-reading
                                            [count] => 1
                                        )

                                )

                        )

                )

            [book_links] => SimpleXMLElement Object
                (
                    [book_link] => Array
                        (
                            [0] => SimpleXMLElement Object
                                (
                                    [id] => 8
                                    [name] => SimpleXMLElement Object
                                        (
                                        )

                                    [link] => http://www.goodreads.com/book_link/follow/8?book_id=2102050
                                )

                            [1] => SimpleXMLElement Object
                                (
                                    [id] => 1027
                                    [name] => SimpleXMLElement Object
                                        (
                                        )

                                    [link] => http://www.goodreads.com/book_link/follow/1027?book_id=2102050
                                )

                            [2] => SimpleXMLElement Object
                                (
                                    [id] => 9
                                    [name] => SimpleXMLElement Object
                                        (
                                        )

                                    [link] => http://www.goodreads.com/book_link/follow/9?book_id=2102050
                                )

                            [3] => SimpleXMLElement Object
                                (
                                    [id] => 4
                                    [name] => SimpleXMLElement Object
                                        (
                                        )

                                    [link] => http://www.goodreads.com/book_link/follow/4?book_id=2102050
                                )

                            [4] => SimpleXMLElement Object
                                (
                                    [id] => 2
                                    [name] => SimpleXMLElement Object
                                        (
                                        )

                                    [link] => http://www.goodreads.com/book_link/follow/2?book_id=2102050
                                )

                            [5] => SimpleXMLElement Object
                                (
                                    [id] => 10
                                    [name] => SimpleXMLElement Object
                                        (
                                        )

                                    [link] => http://www.goodreads.com/book_link/follow/10?book_id=2102050
                                )

                            [6] => SimpleXMLElement Object
                                (
                                    [id] => 5
                                    [name] => SimpleXMLElement Object
                                        (
                                        )

                                    [link] => http://www.goodreads.com/book_link/follow/5?book_id=2102050
                                )

                            [7] => SimpleXMLElement Object
                                (
                                    [id] => 2102
                                    [name] => SimpleXMLElement Object
                                        (
                                        )

                                    [link] => http://www.goodreads.com/book_link/follow/2102?book_id=2102050
                                )

                            [8] => SimpleXMLElement Object
                                (
                                    [id] => 1602
                                    [name] => SimpleXMLElement Object
                                        (
                                        )

                                    [link] => http://www.goodreads.com/book_link/follow/1602?book_id=2102050
                                )

                            [9] => SimpleXMLElement Object
                                (
                                    [id] => 107
                                    [name] => SimpleXMLElement Object
                                        (
                                        )

                                    [link] => http://www.goodreads.com/book_link/follow/107?book_id=2102050
                                )

                            [10] => SimpleXMLElement Object
                                (
                                    [id] => 7
                                    [name] => SimpleXMLElement Object
                                        (
                                        )

                                    [link] => http://www.goodreads.com/book_link/follow/7?book_id=2102050
                                )

                            [11] => SimpleXMLElement Object
                                (
                                    [id] => 1
                                    [name] => SimpleXMLElement Object
                                        (
                                        )

                                    [link] => http://www.goodreads.com/book_link/follow/1?book_id=2102050
                                )

                        )

                )

            [series_works] => SimpleXMLElement Object
                (
                    [0] => 
    
  
                )

        )

)

Open in new window


the iframe sits at $xml->book-> reviews_widget but there is only an SimpleXMLElement Object

many thanks
0
 
LVL 9

Expert Comment

by:rinfo
ID: 37786510
Firstly iframe are a page by them selves which may or maynot reside in the same server
and it does have a source address like a normal page.
In order to get iframe you have to first get the whole page into a string .
Parse the string for  the url of the iframe then load  that ifram page source into another string.
$pattern = '/\.*src=\".*\.html"\.*/';
$iframeSrc = preg_match($pattern, $response, $matches);
$src = $matches[0]; // it at all $matches  > 0
$iframeContents = file_get_contents($src);
0
 

Author Comment

by:MK15
ID: 37786539
Hi,

Thank you for the solution, i was wondering if you could put that into the context of my code for me please, so i may test it as i am fairly new at understanding curl and xml parsing.  your help is very much appreciated.

$bookurl = 'http://www.goodreads.com/book/isbn?isbn=184719088X&format=xml&user_id='.$GoodReads_API_KEY;
// specific url to request a book, this can be build dynamically by inserting different methods where it says book_url and such. See the API docs to see more about how the different URLs should be look

$ch = curl_init(); // Initialize curl  handle
curl_setopt($ch, CURLOPT_TIMEOUT, 5); // 5 second timeout
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return the result on success, rather than just TRUE
curl_setopt($ch, CURLOPT_URL, $bookurl); // Set the url for curl to request to

$response = curl_exec($ch); // makes the request and gets the response
$info = curl_getinfo($ch);

// Process $response as xml 
$xml = new SimpleXMLElement($response);
echo '<pre>';
print_r( $xml);
echo '</pre>'

Open in new window


many thanks
0
 
LVL 9

Expert Comment

by:rinfo
ID: 37786589
After this line
$response = curl_exec($ch);
add these lines
$pattern = '/\.*src=\".*\.html"\.*/';
$iframeSrc = preg_match($pattern, $response, $matches);
if (isset($matches)
{
$src = $matches[0]; // it at all $matches  > 0
$iframeContents = file_get_contents($src);
echo $iframeContents;
}
this should display source code for the iframe page.
0
 

Author Comment

by:MK15
ID: 37786614
thanks for that, i am just receiving an error stating of a  Undefined offset: 0 at $src = $matches[0] ....

just to note $matches is empty

thanks
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 9

Expert Comment

by:rinfo
ID: 37786667
I suggest have a look at the page in that site where it does uses an iframe . Note how src is defined.
My example assumes that it might be a html page may be it just uses .htm or it could be a
php page  and you might have to replace html with that.
I could not find any iframe in the link you have mentioned in the curl url.
0
 

Author Comment

by:MK15
ID: 37786673
0
 

Author Comment

by:MK15
ID: 37786684
and heres the source code for the html - before parsing

<?xml version="1.0" encoding="UTF-8"?>
<GoodreadsResponse>
  <Request>
    <authentication>true</authentication>
      <key><![CDATA[Fd9jnpihL95KEvsP3KSeEw]]></key>
    <method><![CDATA[book_isbn]]></method>
  </Request>
  <book>
  <id>2102050</id>
  <title><![CDATA[PHP Web 2.0 Mashup Projects]]></title>
  <isbn><![CDATA[184719088X]]></isbn>
  <isbn13><![CDATA[9781847190888]]></isbn13>
  <asin><![CDATA[]]></asin>
  <image_url>http://www.goodreads.com/images/nocover-111x148.jpg</image_url>
  <small_image_url>http://www.goodreads.com/images/nocover-60x80.jpg</small_image_url>
  <publication_year></publication_year>
  <publication_month></publication_month>
  <publication_day></publication_day>
  <publisher></publisher>
  <language_code></language_code>
  <is_ebook>false</is_ebook>
  <description><![CDATA[]]></description>
  <work>
  <best_book_id type="integer">2102050</best_book_id>
  <books_count type="integer">1</books_count>
  <id type="integer">2107414</id>
  <media_type nil="true"></media_type>
  <original_language_id type="integer" nil="true"></original_language_id>
  <original_publication_day type="integer">22</original_publication_day>
  <original_publication_month type="integer">9</original_publication_month>
  <original_publication_year type="integer">2007</original_publication_year>
  <original_title>PHP Web 2.0 Mashup Projects: Practical PHP Mashups with Google Maps, Flickr, Amazon, YouTube, MSN Search, Yahoo!</original_title>
  <rating_dist>total:10|5:1|4:5|3:3|2:1|1:0|</rating_dist>
  <ratings_count type="integer">10</ratings_count>
  <ratings_sum type="integer">36</ratings_sum>
  <reviews_count type="integer">20</reviews_count>
  <text_reviews_count type="integer">1</text_reviews_count>
</work>

  <average_rating><![CDATA[3.60]]></average_rating>
  <num_pages><![CDATA[]]></num_pages>
  <format><![CDATA[]]></format>
  <edition_information><![CDATA[]]></edition_information>
  <ratings_count><![CDATA[10]]></ratings_count>
  <text_reviews_count><![CDATA[1]]></text_reviews_count>
  
  <url><![CDATA[http://www.goodreads.com/book/show/2102050.PHP_Web_2_0_Mashup_Projects]]></url>
  <link><![CDATA[http://www.goodreads.com/book/show/2102050.PHP_Web_2_0_Mashup_Projects]]></link>
  
    

<authors>
    <author>
    <id>804036</id>
        <name><![CDATA[Shu-Wai Chow]]></name>
    <image_url><![CDATA[http://www.goodreads.com/images/nophoto/nophoto-U-200x266.jpg]]></image_url>
    <small_image_url><![CDATA[http://www.goodreads.com/images/nophoto/nophoto-U-50x66.jpg]]></small_image_url>
    <link><![CDATA[http://www.goodreads.com/author/show/804036.Shu_Wai_Chow]]></link>
    <average_rating>3.60</average_rating>
    <ratings_count>10</ratings_count>
    <text_reviews_count>1</text_reviews_count>
  </author>
  </authors>
    
    <reviews_widget>
      <![CDATA[
        <style>
  #goodreads-widget {
    font-family: georgia, serif;
    padding: 18px 0;
    width:565px;
  }
  #goodreads-widget h1 {
    font-weight:normal;
    font-size: 16px;
    border-bottom: 1px solid #BBB596;
    margin-bottom: 0;
  }
  #goodreads-widget a {
    text-decoration: none;
    color:#660;
  }
  iframe{
    background-color: #fff;
  }
  #goodreads-widget a:hover { text-decoration: underline; }
  #goodreads-widget a:active {
    color:#660;
  }
  #gr_footer {
    width: 100%;
    border-top: 1px solid #BBB596;
    text-align: right;
  }
  #goodreads-widget .gr_branding{
    color: #382110;
    font-size: 11px;
    text-decoration: none;
    font-family: verdana, arial, helvetica, sans-serif;
  }
</style>
<div id="goodreads-widget">
  <div id="gr_header"><h1><a href="http://www.goodreads.com/book/show/2102050.PHP_Web_2_0_Mashup_Projects">PHP Web 2.0 Mashup Projects Reviews</a></h1></div>
  <iframe id="the_iframe" src="http://www.goodreads.com/api/reviews_widget_iframe?did=DEVELOPER_ID&amp;isbn=184719088X&amp;links=660&amp;min_rating=&amp;review_back=fff&amp;stars=fff&amp;text=000" width="565" height="400" frameborder="0"></iframe>
  <div id="gr_footer">
    <a href="http://www.goodreads.com/book/show/2102050.PHP_Web_2_0_Mashup_Projects?utm_medium=api&amp;utm_source=reviews_widget" class="gr_branding" target="_blank">Reviews from Goodreads.com</a>
  </div>
</div>

      ]]>
    </reviews_widget>
  
  <popular_shelves>
          <shelf name="to-read" count="6"/>
          <shelf name="computers" count="1"/>
          <shelf name="it" count="1"/>
          <shelf name="technical" count="1"/>
          <shelf name="techbooks" count="1"/>
          <shelf name="tech" count="1"/>
          <shelf name="ebook" count="1"/>
          <shelf name="currently-reading" count="1"/>
      </popular_shelves>
  <book_links>
    <book_link>
  <id>8</id>
  <name><![CDATA[WorldCat]]></name>
  <link>http://www.goodreads.com/book_link/follow/8?book_id=2102050</link>
</book_link><book_link>
  <id>1027</id>
  <name><![CDATA[Kobo]]></name>
  <link>http://www.goodreads.com/book_link/follow/1027?book_id=2102050</link>
</book_link><book_link>
  <id>9</id>
  <name><![CDATA[Indigo]]></name>
  <link>http://www.goodreads.com/book_link/follow/9?book_id=2102050</link>
</book_link><book_link>
  <id>4</id>
  <name><![CDATA[Abebooks]]></name>
  <link>http://www.goodreads.com/book_link/follow/4?book_id=2102050</link>
</book_link><book_link>
  <id>2</id>
  <name><![CDATA[Half.com]]></name>
  <link>http://www.goodreads.com/book_link/follow/2?book_id=2102050</link>
</book_link><book_link>
  <id>10</id>
  <name><![CDATA[Audible]]></name>
  <link>http://www.goodreads.com/book_link/follow/10?book_id=2102050</link>
</book_link><book_link>
  <id>5</id>
  <name><![CDATA[Alibris]]></name>
  <link>http://www.goodreads.com/book_link/follow/5?book_id=2102050</link>
</book_link><book_link>
  <id>2102</id>
  <name><![CDATA[iBookstore]]></name>
  <link>http://www.goodreads.com/book_link/follow/2102?book_id=2102050</link>
</book_link><book_link>
  <id>1602</id>
  <name><![CDATA[Google eBooks]]></name>
  <link>http://www.goodreads.com/book_link/follow/1602?book_id=2102050</link>
</book_link><book_link>
  <id>107</id>
  <name><![CDATA[Better World Books]]></name>
  <link>http://www.goodreads.com/book_link/follow/107?book_id=2102050</link>
</book_link><book_link>
  <id>7</id>
  <name><![CDATA[IndieBound]]></name>
  <link>http://www.goodreads.com/book_link/follow/7?book_id=2102050</link>
</book_link><book_link>
  <id>1</id>
  <name><![CDATA[Amazon]]></name>
  <link>http://www.goodreads.com/book_link/follow/1?book_id=2102050</link>
</book_link>
  </book_links>
  <series_works>
    
  </series_works>
  
    
  
</book>

</GoodreadsResponse><br />
<font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Undefined offset: 0 in /Applications/MAMP/htdocs/goodread.php on line <i>18</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0048</td><td bgcolor='#eeeeec' align='right'>639056</td><td bgcolor='#eeeeec'>{main}(  )</td><td title='/Applications/MAMP/htdocs/goodread.php' bgcolor='#eeeeec'>../goodread.php<b>:</b>0</td></tr>
</table></font>
<br />
<font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>
<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Warning: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: Filename cannot be empty in /Applications/MAMP/htdocs/goodread.php on line <i>20</i></th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr>
<tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0048</td><td bgcolor='#eeeeec' align='right'>639056</td><td bgcolor='#eeeeec'>{main}(  )</td><td title='/Applications/MAMP/htdocs/goodread.php' bgcolor='#eeeeec'>../goodread.php<b>:</b>0</td></tr>
<tr><td bgcolor='#eeeeec' align='center'>2</td><td bgcolor='#eeeeec' align='center'>1.6287</td><td bgcolor='#eeeeec' align='right'>658208</td><td bgcolor='#eeeeec'><a href='http://www.php.net/file_get_contents' target='_new'>file_get_contents</a>
(  )</td><td title='/Applications/MAMP/htdocs/goodread.php' bgcolor='#eeeeec'>../goodread.php<b>:</b>20</td></tr>
</table></font>

Open in new window

0
 
LVL 9

Expert Comment

by:rinfo
ID: 37786707
try this
$pattern ='/\http://www.goodreads.com/api/reviews_widget_iframe*/';
$iframeSrc = preg_match($pattern, $response, $matches);
if (isset($matches)
{
$src = $matches[0]; // it at all $matches  > 0
$iframeContents = file_get_contents($src);
echo $iframeContents;
}
0
 

Author Comment

by:MK15
ID: 37786751
hi i really appreciate your support.
I am receiving error Warning: preg_match() [function.preg-match]: Unknown modifier '/'

thanks
0
 
LVL 9

Accepted Solution

by:
rinfo earned 500 total points
ID: 37787652
I am not that good in regexpr but this might help you

foreach(preg_split("/(\r?\n)/", $response) as $line)
{
    if (strstr("<iframe id",$line))
       echo $line;
}
here $response is the source code for the html - before parsing - submitted by you.
0
 

Author Comment

by:MK15
ID: 37789683
thanks mate, it did the trick
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now