Non Fatal Error Dom Parser
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you
Fatal Error Call To A Member Function Find() On A Non-object In Php
might have Meta Discuss the workings and policies of this call to a member function find() on boolean in site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers simple html dom error handling or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community
Call To A Member Function Find() On String
of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up simple html dom parser can't get correct value up vote 0 down vote favorite I scrape using simple html dom parser include 'simple_html_dom.php'; function getSslPage($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_HEADER, false);
Call To A Member Function Find() On Boolean Cakephp
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_REFERER, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $result = curl_exec($ch); curl_close($ch); return $result; } $html = getSslPage('http://forum.xda-developers.com/note-4-sprint'); $result = $html->find('.forumbox-header',0); //error here echo $result; I execpt the output will be Sprint Samsung Galaxy Note 4 which has class of forumbox-header. I have no idea I got an error saying Fatal error: Call to a member function find() on a non-object there. php web-scraping simple-html-dom share|improve this question asked May 10 '15 at 11:19 Elton Jamie 286211 $result is a string as it's getting the return value from the URL you've requested. It's not an object. –Jon Stirling May 10 '15 at 11:28 Also, given the code provided, it doesn't look like you actually use simple html dom at all. P.s. perhaps using the built in DOM functionality might be worth a look too. –Jon Stirling May 10 '15 at 11:31 @JonStirling are you sure? When I do ec
Simple HTML DOM Parser A php based DOM parser. Brought to you by: john_schlick, me578022 Summary Files Reviews Support Code Tickets ▾ Feature Requests Patches call to a member function find() on a non-object cakephp Support Requests Bugs News Discussion Create Ticket View Stats Group v1.0_(example)
Str_get_html Not Working
Searches Changes Closed Tickets Open Tickets Help Formatting Help #108 html->find error Status: open Owner: nobody Labels: None call to a member function find on null Priority: 5 Updated: 2014-10-19 Created: 2012-07-10 Creator: Nigel Private: No When I run the example php script I get an error: Fatal error: Call to a member function find() http://stackoverflow.com/questions/30150765/simple-html-dom-parser-cant-get-correct-value on a non-object in /mnt/133/sda/0/9/nigelstrang59/htmltry.php on line 6 - it seems to be saying that $html is not an object .... here is the code (almost a copy paste from sourceforge) - any ideas? find(\'a\'); echo $ret; https://sourceforge.net/p/simplehtmldom/bugs/108/ ?> thanks Discussion Nigel - 2012-07-10 please note the \ preceding the " are not present in the code If you would like to refer to this comment somewhere else in this project, copy and paste the following link: nickl- - 2012-09-10 This fatal error usually appears when trying to use null or something else as an object, iow using the -> to call a method. Chances are that for whatever reason file_get_html returned null or false, should verify this. To take simple_html_dom completely out of the equation see if you are able to fetch the url with file_get_contents(). Please let us know what you find, if you still don't have any luck may I ask that you give a more detailed report including version numbers and step by step process so that someone may reproduce the fault. I did your example without the escaped string quotes and it worked. You could also try: $html = new simple_html_dom(); $dom = $html->load_file('http://www.google.com/'); if (!empty($dom)) $dom->find('a'); Also try something other than google not always the friendliest approach
the PHP Simple HTML DOM Parser Fatal error: Call to a member function find() on a non-object PHP Simple HTML DOM Parser was used to create a simple search function to parse http://www.canbike.org/information-technology/php-fatal-error-call-to-a-member-function-find-on-a-non-object.html tables on CANbike.org. Some of these tables are growing in size with new data. https://xerces.apache.org/xerces2-j/faq-dom.html Unfortunately after updating the large "realestate" table, the search function no longer worked. The following message occured . . . Fatal error: Call to a member function find() on a non-object in /../search.php on line 71 Checking the line revealed $html->find('') as the culprit; which seemed odd as the function worked in the past. Anyway, call to after checking the table there were no errors to be found. As a result, rows of data were removed from the table in order to test the find function again. Surprisingly everything worked. The next test was to restore the original table and check the contents of $html = file_get_html('realestate.php');. Surprisingly the contents were empty. However, when the html table was reduced in size, the file was retrieved call to a into the variable $html without issue. Well, there was no memory issue. Obviously a file size limitation had been imposed. Solution: Set a New PHP Simple HTML DOM Parser MAX_FILE_SIZE Fortunately, the solution was simple. On line 66, of simple_html_dom.php was define('MAX_FILE_SIZE', 600000); a variable to define the maximum file size. An extra zero was added to the end, and the search function worked again! Final Word: Error Checking A solution was found, but a precautionary conditional statement should be added to check the variable html contents are set before calling find(). $html = file_get_html('realestate.php'); if($html && is_object($html) && isset($html->nodes)){ foreach($html->find('') as $element){ ... } } Related Item(s): PHP: Detect Linux or Windows Server PHP: Simple Password Protection with Session Timeout PHP Form: Clear Data on Refresh or Back Button Press Info & Tech Archives By Month November 2015 October 2015 September 2015 July 2015 June 2015 May 2015 March 2015 February 2015 January 2015 December 2014 November 2014 October 2014 August 2014 July 2014 June 2014 May 2014 April 2014 March 2014 February 2014 January 2014 November 2013 October 2013 September 2013 August 2013 July 2013 June 2013 May 2013 March 2013 February 2013 January 2013 Syndicate Info & Tech RSS Feed CANbi
higherXML Schema API and DOMRevalidation of DOM document in MemoryHandling Errors in DOMControlling Entity RepresentationAssociating user data with a NodeMaking getElementById workSetting ID attributeAccessing type informationAnswersIs Xerces DOM implementation thread-safe? No. DOM does not require implementations to be thread safe. If you need to access the DOM from multiple threads, you are required to add the appropriate locks to your application code. How do I create a DOM parser? You can create a DOM parser by using the Java APIs for XML Processing (JAXP) or using the DOM Level 3 Load and Save. The following source code shows how to create the parser with JAXP: import java.io.IOException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.xml.sax.SAXException; ... String xmlFile = "file:///xerces-2_11_0/data/personal.xml"; try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse(xmlFile); } catch (FactoryConfigurationError e) { // unable to get a document builder factory } catch (ParserConfigurationException e) { // parser was unable to be configured catch (SAXException e) { // parsing error } catch (IOException e) { // i/o error } The following source code shows how to create the parser using DOM Level 3: import org.w3c.dom.bootstrap.DOMImplementationRegistry; import org.w3c.dom.Document; import org.w3c.dom.ls.DOMImplementationLS; import org.w3c.dom.ls.LSParser; ... DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance(); DOMImplementationLS impl = (DOMImplementationLS)registry.getDOMImplementation("LS"); LSParser builder = impl.createLSParser( DOMImplementationLS.MODE_SYNCHRONOUS, null); Document document = builder.parseURI("data/personal.xml"); You can now use DOM Level 3 Load/Save and Core interfaces