simple-html-dom

How to use file_get_contents or file_get_html?

风流意气都作罢 提交于 2019-11-28 01:51:36
I've read through quite a few questions on here and I'm not sure if I should be using file_get_contents or file_get_html for this. All that I'm trying to do is use PHP to display the two tables from this page on my website: http://www.statmyweb.com/recently-analyzed/ I know how to get their full page and display it on my site of course, but I can't figure out how I'm able to just pull those two tables without also getting the header/footer. You are not able to specify in file_get_contents() just to retrieve the tables. You would have to get the return value of file_get_contents() using:

Simple html dom character encoding issue

拜拜、爱过 提交于 2019-11-28 01:32:07
问题 hey guys, i'm using simple html dom to retrieve content from another website, but the thing is theres a character encoding issue with the stuff retrieved using simple html dom. The characters are showing up as the little diamond with the question mark inside. The character encoding issue only happens with the content retrieved, and all other text on my site is displaying fine. If anyone could help that would be great. 回答1: Try using iconv to convert the charset of the scraped text to the

how to use CURL and PHP Simple HTML DOM Parser with object

ⅰ亾dé卋堺 提交于 2019-11-27 22:38:32
Using CURL to get content from website. Getting response in object. How to convert that object in to PHP Simple HTML DOM Parser function get_data($url) { $ch = curl_init(); $timeout = 30; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,false); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); curl_setopt($ch,CURLOPT_POST,false); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:10.0) Gecko/20100101 Firefox/10.0"); //curl_exec($ch); $dom = new simple_html_dom(curl_exec($ch)); print_r( $dom ); curl_close($ch); return $data; } $url = 'http:/

PHP HTML DOM Parser [duplicate]

╄→гoц情女王★ 提交于 2019-11-27 22:10:52
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How to parse and process HTML with PHP? I'm looking into HTML DOM parsers for PHP. I've found PHP Simple HTML DOM Parser. Are there any others I should be looking at? 回答1: Yes. Simple html doc is fine, but an order of magnitude slower than the built in dom parser. $dom = new DOMDocument(); @$dom->loadHTML($html); $x = new DOMXPath($dom); foreach($x->query("//a") as $node) { $data['dom']['href'][] = $node-

Warning: file_get_contents: failed to open stream: Redirection limit reached, aborting

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 15:40:58
I read over 20 related questions on this site, searched in Google but no use. I'm new to PHP and am using PHP Simple HTML DOM Parser to fetch a URL. While this script works with local test pages, it just won't work with the URL that I need the script for. Here is the code that I wrote for this, following an example file that came with the PHP Simple DOM parser library: <?php include('simple_html_dom.php'); $html = file_get_html('http://www.farmersagent.com/Results.aspx?isa=1&name=A&csz=AL'); foreach($html->find('li.name ul#generalListing') as $e) echo $e->plaintext; ?> And this is the error

Simple html dom file_get_html not working - is there any workaround?

时光总嘲笑我的痴心妄想 提交于 2019-11-27 01:38:38
<?php // Report all PHP errors (see changelog) error_reporting(E_ALL); include('inc/simple_html_dom.php'); //base url $base = 'https://play.google.com/store/apps'; //home page HTML $html_base = file_get_html( $base ); //get all category links foreach($html_base->find('a') as $element) { echo "<pre>"; print_r( $element->href ); echo "</pre>"; } $html_base->clear(); unset($html_base); ?> I have the above code and I'm trying to get certain elements of the Play Store page but it isn't returning anything. Is it possible that certain PHP functions might be disabled on the server to stop that? The

how to use CURL and PHP Simple HTML DOM Parser with object

萝らか妹 提交于 2019-11-26 23:06:37
问题 Using CURL to get content from website. Getting response in object. How to convert that object in to PHP Simple HTML DOM Parser function get_data($url) { $ch = curl_init(); $timeout = 30; curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,false); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); curl_setopt($ch,CURLOPT_POST,false); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:10.0) Gecko/20100101 Firefox/10.0"); //curl_exec($ch); $dom =

Warning: file_get_contents: failed to open stream: Redirection limit reached, aborting

只谈情不闲聊 提交于 2019-11-26 17:16:02
问题 I read over 20 related questions on this site, searched in Google but no use. I'm new to PHP and am using PHP Simple HTML DOM Parser to fetch a URL. While this script works with local test pages, it just won't work with the URL that I need the script for. Here is the code that I wrote for this, following an example file that came with the PHP Simple DOM parser library: <?php include('simple_html_dom.php'); $html = file_get_html('http://www.farmersagent.com/Results.aspx?isa=1&name=A&csz=AL');

Simple html dom file_get_html not working - is there any workaround?

扶醉桌前 提交于 2019-11-26 09:44:43
问题 <?php // Report all PHP errors (see changelog) error_reporting(E_ALL); include(\'inc/simple_html_dom.php\'); //base url $base = \'https://play.google.com/store/apps\'; //home page HTML $html_base = file_get_html( $base ); //get all category links foreach($html_base->find(\'a\') as $element) { echo \"<pre>\"; print_r( $element->href ); echo \"</pre>\"; } $html_base->clear(); unset($html_base); ?> I have the above code and I\'m trying to get certain elements of the Play Store page but it isn\'t

Simple HTML Dom: How to remove elements?

不问归期 提交于 2019-11-26 05:35:06
问题 I would like to use Simple HTML DOM to remove all images in an article so I can easily create a small snippet of text for a news ticker but I haven\'t figured out how to remove elements with it. Basically I would do Get content as HTML string Remove all image tags from content Limit content to x words Output. Any help? 回答1: There is no dedicated methods for removing elements. You just find all the img elements and then do $e->outertext = ''; 回答2: when you only delete the outer text you delete