YQL: html table is no longer supported

后端 未结 4 1324
渐次进展
渐次进展 2020-11-28 09:51

I use YQL to get some html-pages for reading information out of it. Since today I get the return message \"html table is no longer supported. See https://policies.yahoo.com/

4条回答
  •  隐瞒了意图╮
    2020-11-28 10:06

    Thank you very much for your code.

    It helped me to create my own script to read those pages which I need. I never programmed PHP before, but with your code and the wisdom of the internet I could change your script to my needs.

    PHP

    loadHTML($html);
    
        // apply xpath filter
        $xpath = new DOMXPath($dom);
        $elements = $xpath->query($xpathQuery);
        $temp_dom = new DOMDocument();
        foreach($elements as $n)   $temp_dom->appendChild($temp_dom->importNode($n,true));
        $renderedHtml = $temp_dom->saveHTML();
    
        // return html in json response
        // json structure: 
        // {html: "xxxx"}
        $post_data = array(
          'html' => $renderedHtml
        );  
        echo json_encode($post_data); 
    
    ?>
    

    Javascript

    $.ajax({
        url: "url of service",
        dataType: "json", 
        data: { url: url,
                xpath: "//*"
              },
        type: 'GET',
        success: function() {
                 },
        error: function(data) {
               }
    }); 
    

提交回复
热议问题