【问题标题】:PHP Simple Html Dom parsing a php formPHP Simple Html Dom 解析一个 php 表单
【发布时间】:2014-01-18 17:08:32
【问题描述】:

我有这个 php 页面:

exercice_submit.php?exerciseId=7

里面有几个嵌套的div

<div id="container">
<div id="content">
<div id="content_main">

在最后一个 div 里面有一个表单:

<form action="/modules/exercice/exercice_submit.php" method="post">

我想剪掉所有其他的 html 标签,只保留表单中包含的内容。 你能帮我解析一下这个页面吗?

我用的是PHP Simple HTML DOM,我写的:

    // example of how to use basic selector to retrieve HTML contents
    include('../simple_html_dom.php');
    
    // get DOM from URL or file
    $html = file_get_html('exercice/exercice_submit.php');
    
    echo $html->find("#content_main",0);
    echo $html->outertext
    
    ?>

这似乎不起作用。如果你能帮助我,也许你知道一种将提交按钮目标更改为提交到不同 php 的方法。

提前感谢所有可能的答案。

【问题讨论】:

  • 请从$html发布标记

标签: php html parsing dom


【解决方案1】:

我没有使用过 file_get_html,但您可以使用 file_get_contents 将其加载到字符串中,然后在 "

" 上使用 substr 和 strpos 来获取表单。

http://www.php.net/manual/en/function.strpos.php

http://www.php.net/manual/en/function.substr.php

http://www.php.net/file_get_contents

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多