-1

长期读者,第一次海报。

我正在创建一个表单,该表单将从特定 url 获取某些值并获取该值并使用 $_GET 发布特定信息/值。

让我们将此 URL 称为 examplecode.com/someindex.html,在此我会看到:<td class="ColumnMargin"><label for="quote_Customer_Name">Contact:</label></td><td class="QuoteNameText"><input class="TabOnEnter widenFieldsWidth" id="quote_Customer_Name" name="quote_Customer_Name" tabindex="110" type="text" value="JOHN DOE" /></td>

我已经搜索了好几天,我尝试了很多东西,我想做的就是打开这个 URL,检查它,找到 id "quote_Customer_Name" 或 name "quote_Customer_Name" 并从中获取值然后回显它在页面上(它是 JOHN DOE)某处。

我是 PHP 代码的初学者,过去我做过一些简单的事情,这超出了我的舒适区,但老实说我不知道​​去哪里找。我希望有人可以帮助我,因为我什至不知道从哪里开始。

先感谢您!:)

4

1 回答 1

-1

有很多方法可以做到这一点。我会给你一个简单的例子,网址是“ Salam Tresno ”。我们将获取它的 h1 标签并显示它。

<?php

$url = 'url ....';
// fetch html
$html = file_get_contents($url);

// find and match h1 tag
preg_match('#<h1[^><]*>.+?</h1>#', $html, $matches);

print_r($matches);

于 2020-11-19T03:20:10.347 回答