1

Recently our hosting disabled allow_url_fopen, it seems simplehtmldom needs it turned on I saw a work arround with allow_url_fopen in this site simplehtmldom.sourceforge.net...aq.htm#hosting, "Use curl to get the page, then call "str_get_dom" to create DOM object". but still to no luck. can you tell me if I did it properly or am I missing something?

<?php 
$curl = curl_init();  
curl_setopt($curl, CURLOPT_URL, 'www.weather.bm/');   
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);   
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);   
$str = curl_exec($curl);   
curl_close($curl);   
$html= str_get_html($str);  
?> 
<?php  
$element = $html->find("div");  
$element[66]->class = "mwraping66"; 
foreach($html->find('.mwraping66 img') as $e) 

$doc = phpQuery::newDocumentHTML( $e );  $containers = pq('.mwraping66', $doc);    
foreach ( $containers as $container ) {     $div = pq('img', $container);       
$div->eq(1)->removeAttr('style')->addClass('thumbnail')->html( pq( 'img', $div->eq(1))-    >removeAttr('height')->removeAttr('width')->removeAttr('alt') );  
}  print $doc;  
?> 
<?php  
$element = $html->find("div");   
$element[31]->class = "mwraping31";  
foreach($html->find('.mwraping31') as $e)  
echo $e->plaintext;   
?>................................. 

compared to:

<?php 
include('simple_html_dom.php'); 
include ('phpQuery.php');    
// Create DOM from URL 
$html = file_get_html('www.weather.bm/'); 
?> 
<?php  
$element = $html->find("div");  
$element[66]->class = "mwraping66"; 
foreach($html->find('.mwraping66 img') as $e).....

Thanks you for your help

3
  • You can likely reenable allow_url_fopen via .htaccess. As for your curl snippet, you should pass a complete http:// url to CURLOPT_URL, not just a domain name. Commented Apr 13, 2011 at 17:55
  • I tried .htaccess but did not work It seems our hosting disabled it permanently, as for the http:// I just forgot to include it in the post sorry. Commented Apr 13, 2011 at 18:01
  • i also have same doubt...if any one knew answer please post Commented Apr 11, 2012 at 10:44

1 Answer 1

1

I know this is too late to answer this query but i have found similar questions and answer in this forum.. this is the link to that Using simple html dom .. i am not sure whether this will answer your query because i am also new to dom .try to use this modified simple_html_dom.php file http://webarto.com/82/php-simple-html-dom-curl it uses curl instead of file_get_content; this file is working for me and its usage is also same as the original simple_html_dom.php

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.