我的目標網站包含這樣獲取元素通過ID或用戶名在捲曲
<form>
<input type="text" name="suggest" value="www.google.com">
<input type="submit" value="submit">
</form>
代碼我用捲曲的PHP得到這個頁面
<?php
$url="http://mysite.com";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
$result = curl_exec ($ch);
echo $result;
curl_close($ch);
?>
如何使用ID或名字,我得到一個元素值?例如輸入名稱中的「www.google.com」=「建議」。感謝您的幫助。
我不能使用此代碼進行遠程是這樣的:
<?php
require 'Path/QueryPath.php';
qp('http://hipfile.com/bbgfom5ej9tm/zakhme_shaneie_haava_dvdrip.wmv.html/')-
find('[password="login"]')->writeHTML(); ?>
,並返回該錯誤
Fatal error: Uncaught exception 'QueryPathParseException' with message 'DOMDocument::load() [domdocument.load]: AttValue: " or ' expected in http://hipfile.com/bbgfom5ej9tm/zakhme_shaneie_haava_dvdrip.wmv.html/ , line: 18 (C:\xampplite\htdocs\test1\Path\QueryPath.php: 2106)' in C:\xampplite\htdocs\test1\Path\QueryPath.php:2346 Stack trace: #0 [internal function]: QueryPathParseException::initializeFromError(2, 'DOMDocument::lo...', 'C:\xampplite\ht...', 2106, Array) #1 C:\xampplite\htdocs\test1\Path\QueryPath.php(2106): DOMDocument->load('http://hipfile....', 0) #2 C:\xampplite\htdocs\test1\Path\QueryPath.php(179): QueryPath->parseXMLFile('http://hipfile....', NULL, NULL) #3 C:\xampplite\htdocs\test1\Path\QueryPath.php(23): QueryPath->__construct('http://hipfile....', NULL, Array) #4 C:\xampplite\htdocs\test1\index.php(3): qp('http://hipfile....') #5 {main} thrown in C:\xampplite\htdocs\test1\Path\QueryPath.php on line 2346
能幫我嗎?我使用了兩個DOM和simplehtmldom,但沒有爲我工作。它僅適用於本地頁面。
這可能是有用的:http://simplehtmldom.sourceforge.net/ –
的QueryPath是新simplehtmldom –