tazeha Posted August 12, 2014 Share Posted August 12, 2014 hello I write this script with simple_html_do parser lib. now how can I save results I use $html->save('result.htm'); but display main web page url not my result <?phpinclude_once('simple_html_dom.php');// Create DOM from URL$html= file_get_html("http://www.digionline.ir/Allprovince/viewcat/%D9%82%DB%8C%D9%85%D8%AA-%D8%AE%D8%B1%DB%8C%D8%AF-%D9%81%D8%B1%D9%88%D8%B4-%D9%85%D8%B4%D8%AE%D8%B5%D8%A7%D8%AA-%D9%87%D8%A7%D8%B1%D8%AF-%D8%AF%D9%8A%D8%B3%D9%83-%D9%83%D8%A7%D9%85%D9%BE%D9%8A%D9%88%D8%AA%D8%B1/cat=20101",10);foreach($html->find('ul#product-page-product') as $ul) {{ foreach($ul->find('li') as $li) { $item['title']= $li->find('span.product-page-detail-wrapper-text', 0)->plaintext; $item['price'] = $li->find('span.product-detail-wrapper-price', 0)->plaintext; $lis[] = $item; }} } $ul = array();echo$titles="<b>نام محصول:</b>". $item['title'] . "</br> ";echo$prices="<b>قیمت:</b>". $item['price'] . "</br> ";echo$titles="<b>نام محصول:</b>". $item['title'] . "</br> ";echo$prices="<b>قیمت:</b>". $item['price'] . "</br> ";$html->save('result.htm');?> Thank's Link to comment Share on other sites More sharing options...
justsomeguy Posted August 12, 2014 Share Posted August 12, 2014 I'm not sure what you're asking. What are you trying to save if not the HTML that you got from the remote page? Link to comment Share on other sites More sharing options...
tazeha Posted August 15, 2014 Author Share Posted August 15, 2014 I want display in result.htm display this : $titles="<b>نام محصول:</b>". $item['title'] . "</br> ";echo$prices="<b>قیمت:</b>". $item['price'] . "</br> ";echo$titles="<b>نام محصول:</b>". $item['title'] . "</br> ";echo$prices="<b>قیمت:</b>". $item['price'] . "</br> "; : led قیمت: 25000 ,.. but when use $html->save('result.htm') displaying main web pag of $html= file_get_html("http://www.digionline.ir/Allprovince/viewcat/%D9%82%DB%8C%D9%85%D8%AA-%D8%AE%D8%B1%DB%8C%D8%AF-%D9%81%D8%B1%D9%88%D8%B4-%D9%85%D8%B4%D8%AE%D8%B5%D8%A7%D8%AA-%D9%87%D8%A7%D8%B1%D8%AF-%D8%AF%D9%8A%D8%B3%D9%83-%D9%83%D8%A7%D9%85%D9%BE%D9%8A%D9%88%D8%AA%D8%B1/cat=20101",10); .. please run top script.. Link to comment Share on other sites More sharing options...
justsomeguy Posted August 15, 2014 Share Posted August 15, 2014 Using $html->save saves the document in the $html variable. You're just echoing out HTML code. You need to make that code part of the document in the $html variable. Or, if that is the only thing you want to save, then build a string containing everything you want and use file_put_contents to save it to a file. 1 Link to comment Share on other sites More sharing options...
Don Jajo Posted August 23, 2014 Share Posted August 23, 2014 I suggest you paste the content of file_get_html() function 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now