简单的HTML DOM解析器 - 通过表单将变量传递给URL

时间:2011-08-25 22:10:56

标签: php forms parsing dom

我正在尝试构建一个脚本以使工作更轻松。我是PHP的新手,所以请耐心等待。我希望有人能够帮助我。

基本上我有简单的html dom解析器,我需要它做的是在url字符串的末尾添加一个单词。

这是我到目前为止所做的:

<?php
include_once('simple_html_dom.php');
$SNBS_URL = "http://www.facebook.com/". $clientid
$clientid = $_GET["clientid"];
// Create DOM from URL or file
$html = file_get_html($SNBS_URL);
// find all div tags with id=gbar
foreach($html->find('div#foot') as $e)
echo $e->innertext . '<br>';
?>

 <form id="form1" name="form1" method="post" action="extract_html.php">
  Client ID
 <input name="clientid" type="text" id="clientid" value="enter id" />
 </label>
 <input type="submit" name="submit" id="submit" value="Submit" />
 </form>

我使用facebook url作为测试。我需要表单在URL的末尾提交一个字符串并获取html dom解析器来解析最终的url:

www.facebook.com/ +表单提交的关键字

因此,一旦在网页上按下提交按钮,html dom解析器将解析www.facebook.com/keyword.entered。

如果我很难理解,我很抱歉,非常感谢任何帮助。

由于

1 个答案:

答案 0 :(得分:3)

$SNBS_URL = "http://www.facebook.com/". $clientid
$clientid = $_GET["clientid"];

应该是:

$clientid = $_GET["clientid"];
$SNBS_URL = "http://www.facebook.com/". $clientid