Weird error using PHP Simple HTML DOM parser

前端 未结 9 1357
梦谈多话
梦谈多话 2020-11-29 10:30

I am using this library (PHP Simple HTML DOM parser) to parse a link, here\'s the code:

function getSemanticRelevantKeywords($keyword){
    $results = array(         


        
相关标签:
9条回答
  • 2020-11-29 11:09

    Simplest solution to this problem

    if ($html = file_get_html("http://www.semager.de/api/keyword.php?q=". urlencode($keyword) ."&lang=de&out=html&count=2&threshold=") {
    
    } else {
        // do something else because couldn't find html
    }
    
    0 讨论(0)
  • 2020-11-29 11:14

    your script is OK. I receive this error when it doase not find the element that i'm looking for on that page.

    In your case, please check if the page that you are accessing it has 'SPAN' element

    0 讨论(0)
  • 2020-11-29 11:16

    This error usually means that $html isn't an object.

    It's odd that you say this seems to work. What happens if you output $html? I'd imagine that the url isn't available and that $html is null.

    Edit: Looks like this may be an error in the parser. Someone has submitted a bug and added a check in his code as a workaround.

    0 讨论(0)
提交回复
热议问题