获取信息表格phpdom

时间:2015-07-19 19:26:55

标签: php html curl

我正在尝试使用curl获取信息。

大概我得到了所有信息,但我需要单独获取信息。

例如,我使用curl获取td文本。

这是td内容

jsfiddle

我需要提取文本“我的信息”,myinfo href链接和最后一页编号。

我怎么能这样做?

这是我在curl中使用的代码

 $nodes = $finder->evaluate('//td[contains(text(), "") and starts-with(@id, "td_threadtitle_") ]');
        foreach ($nodes as $node) 
            {
        $innerHTML = trim($tmp_dom->saveHTML()); 
        $fh = fopen("test.html", 'w'); // we create the file, notice the 'w'. This is to be able to write to the file once.
        //writing response in newly created file
        fwrite($fh, $node->c14n()); // here we write the data to the file.
        fclose($fh);

  }

2 个答案:

答案 0 :(得分:0)

我的信息

gcp() {
    git add -- .;
    git commit -m \"$1\";
    git push origin $2;
}

它的href

$ gcp "test this" master
error: pathspec 'this"' did not match any file(s) known to git.

最后一页编号

(//td[starts-with(@id, "td_threadtitle_") ]//a[1]/text())[1]

答案 1 :(得分:0)

我按照我的要求试了这个。

请告诉我这是否可以?

    $options = $node->getElementsByTagName('a');
    $post_message_id=$node->getAttribute('id');

        foreach($options as $option) {
             $value = $option->getAttribute('id');

            if($value!=""){
                print_r( $option->getAttribute('href'));
                echo "\n";
                print_r( $option->textContent);
                echo "\n";
                print_r($options->item(($options->length)-1)->getAttribute('href'));
                echo "\n";
            }

        }