【问题标题】:PHP output from HTML input Form [closed]HTML输入表单的PHP输出[关闭]
【发布时间】:2016-09-11 05:16:41
【问题描述】:

让用户在表单文本框中输入一个值,该文本框获取该值并将其放入 $html = file_get_html(' ') 并在页面上回显输出值。

<form action="dex.php" method="POST">
<b>Site:</b><input type="text" name="site" />
<input type="submit" name="submit" value="Search" />
</form>  

<?php
include('simple_html_dom.php');

$html = str_get_html('site');
echo htmlspecialchars($_POST['site']);
$html->find('div', 1)->class = 'bar';
$html->find('div[id=site]', 0)->innertext = 'foo';
//echo $html; here doesn't show webpage just results
$html = file_get_html('http://www.myrobotbuddy.com');
//$html - file_get_html(' '); from form input
echo file_get_html('$html')->plaintext;
echo $html; //shows website also 
?>

【问题讨论】:

  • 你的问题不清楚,也没有告诉你要做什么

标签: php html forms file scraper


【解决方案1】:

我只是猜测你想要达到的目标,但是:

首先将表单输入到一个变量中:

if (isset($_POST['submit'])) {
    $site = htmlspecialchars($_POST['site']);
}

然后:

if(isset($site)){
    $html = str_get_html($site);
}

【讨论】:

  • 谢谢,我不知道怎么问这个问题。只需让用户在输入框中输入一个 http 地址,然后发布抓取的结果。感谢您至少提供了比似乎只想解决每个问题的众多仇恨者更多的机会。谢谢你 Stoycho :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-02
  • 2021-04-14
  • 1970-01-01
  • 2016-01-26
  • 1970-01-01
相关资源
最近更新 更多