Giter VIP home page Giter VIP logo

simple_html_dom's Issues

error line104 unexpected '[' in simple_html_dom.php

Parse error: syntax error, unexpected '[' in D:\xampp\htdocs\wztest\simple_html_dom-master\simple_html_dom-master\simple_html_dom.php on line 104

PHP Version 5.3.8

error line104:
if (!empty($location_headers) && preg_match($pattern, array_values($location_headers)[0], $matches)) {

revised :

 $k = array_values($location_headers);
if (!empty($location_headers) && preg_match($pattern, $k[0], $matches)) {

Simple html

<title>LOGIN</title> <style type=text/css> body {background-color:purple; max-width:100%}

div{
align:center}
input{
color:green
}
center{
color:blue
}

</style>

Log In



Your Username:


Your Password:

PHP 7.2.5

php 7.2.5

PHP Warning: file_get_contents(): stream does not support seeking in simple_html_dom.php on line 90
PHP Warning: file_get_contents(): Failed to seek to position -1 in the stream in simple_html_dom.php on line 90

there is a page

src:

echo file_get_html('http://fex.baidu.com/')->find('title', 0)->plaintext;

I got an error:

Trying to get property of non-object

other url works well, but this one fails.

1372行 if (!preg_match("/^[\w-:]+$/", $tag)) { 错误

WARNING: preg_match(): Compilation failed: invalid range in character class at offset 4 in /home/ymserver/vhost/ios_wall_ads/spider/protected/simplehtmldom/simple_html_dom.php on line 1372

提示这个错误,怎么解决呢?

iconv(): Detected an illegal character in input string

I encountered this problem when I use this code.

iconv(): Detected an illegal character in input string

Then i change

$converted_text = iconv($sourceCharset, $targetCharset//IGNORE, $text);

to

$converted_text = iconv($sourceCharset, "$targetCharset//IGNORE", $text); 

And then pop up the follow error.

iconv(): Detected an incomplete multibyte character in input string.

Final i change the code to

$converted_text = htmlentities($text, ENT_QUOTES, $targetCharset);

It worked fine.

Is there a better way to solve this problem.

doesn't work on windows 10

Hello I was wondering why can't I scrape the data of an html page using

using direct url

$html = file_get_html('http://www.google.com/');

echo $html;

Output:

Warning: file_get_contents(): stream does not support seeking in C:\path\project\simple_dom_html.php on line 75

using file path

 $html = file_get_html('main/users.html');
     var_dump($html);

Instead of Html the Output is:
 ["doc":protected]=>                     
 string(1) ">"                           
 ["char":protected]=>                    
 NULL                                    
 ["cursor":protected]=>                  
 int(2)                                  
 ["parent":protected]=>                  
 object(simple_html_dom_node)#2 (9) {    
   ["nodetype"]=>                        
   int(5)                                
   ["tag"]=>                             
   string(4) "root"                      
   ["attr"]=>                            
   array(0) {                            
   }                                     
   ["children"]=>                        
   array(0) {                            
   }                                     
   ["nodes"]=>                           
   array(1) {                            
     [0]=>                               
     object(simple_html_dom_node)#3 (9) {
       ["nodetype"]=>                    
       int(3)                            
       ["tag"]=>                         
       string(4) "text"                  
       ["attr"]=>                        
       array(0) {                        
       }                                 
       ["children"]=>                    
       array(0) {                        
       }                                 
       ["nodes"]=>                       
       array(0) {                        
       }                                 
       ["parent"]=>                      
       *RECURSION*                       
       ["_"]=>                           
       array(1) {                        
         [4]=>                           
         string(1) ">"                   
       }                                 
       ["tag_start"]=>                   
       int(0)                            
       ["dom":"simple_html_dom_node":priv
       *RECURSION*                       
     }                                   
   }                                     
   ["parent"]=>                          
   NULL                                  
   ["_"]=>                               
   array(2) {                            
     [0]=>                               
     int(-1)                             
     [1]=>                               
     int(2)                              
   }                                     
   ["tag_start"]=>                       
   int(0)                                
   ["dom":"simple_html_dom_node":private]
   *RECURSION*                           
 }                                       
 ["noise":protected]=>                   
 array(0) {                              
 }                                       
 ["token_blank":protected]=>             
 string(4) "                             
                                         
 ["token_equal":protected]=>             
 string(4) " =/>"                        
 ["token_slash":protected]=>             
 string(6) " />                          
       "                                 
 ["token_attr":protected]=>              
 string(2) " >"                          
 ["_charset"]=>                          
 string(5) "UTF-8"                       
 ["_target_charset"]=>                   
 string(5) "UTF-8"                       
 ["default_br_text":protected]=>         
 string(2) "                             
                                         
 ["default_span_text"]=>                 
 string(1) " "                           
 ["self_closing_tags":protected]=>       
 array(9) {                              
   ["img"]=>                             
   int(1)                                
   ["br"]=>                              
   int(1)                                
   ["input"]=>                           
   int(1)                                
   ["meta"]=>                            
   int(1)                                
   ["link"]=>                            
   int(1)                                
   ["hr"]=>                              
   int(1)                                
   ["base"]=>                            
   int(1)                                
   ["embed"]=>                           
   int(1)                                
   ["spacer"]=>                          
   int(1)                                
 }                                       
 ["block_tags":protected]=>              
 array(6) {                              
   ["root"]=>                            
   int(1)                                
   ["body"]=>                            
   int(1)                                
   ["form"]=>                            
   int(1)                                
   ["div"]=>                             
   int(1)                                
   ["span"]=>                            
   int(1)                                
   ["table"]=>                           
   int(1)                                
 }                                       
 ["optional_closing_tags":protected]=>   
 array(11) {                             
   ["tr"]=>                              
   array(3) {                            
     ["tr"]=>                            
     int(1)                              
     ["td"]=>                            
     int(1)                              
     ["th"]=>                            
     int(1)                              
   }                                     
   ["th"]=>                              
   array(1) {                            
     ["th"]=>                            
     int(1)                              
   }                                     
   ["td"]=>                              
   array(1) {                            
     ["td"]=>                            
     int(1)                              
   }                                     
   ["li"]=>                              
   array(1) {                            
     ["li"]=>                            
     int(1)                              
   }                                     
   ["dt"]=>                              
   array(2) {                            
     ["dt"]=>                            
     int(1)                              
     ["dd"]=>                            
     int(1)                              
   }                                     
   ["dd"]=>                              
   array(2) {                            
     ["dd"]=>                            
     int(1)                              
     ["dt"]=>                            
     int(1)                              
   }                                     
   ["dl"]=>                              
   array(2) {                            
     ["dd"]=>                            
     int(1)                              
     ["dt"]=>                            
     int(1)                              
   }                                     
   ["p"]=>                               
   array(1) {                            
     ["p"]=>                             
     int(1)                              
   }                                     
   ["nobr"]=>                            
   array(1) {                            
     ["nobr"]=>                          
     int(1)                              
   }                                     
   ["b"]=>                               
   array(1) {                            
     ["b"]=>                             
     int(1)                              
   }                                     
   ["option"]=>                          
   array(1) {                            
     ["option"]=>                        
     int(1)                              
   }                                     
 }                                       
                                         

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.