[ Поиск ] - [ Пользователи ] - [ Календарь ]
Полная Версия: Вытащить значения input name из html
denlam
через file_get_contents достаю содержимое сайта
и вставляю в переменную $html

Как теперь оттуда вытащить все значения name из всех инпутов? Понимаю, что это нужно делать как-то регуляркой, но не знаю как.
denlam
Цитата (Dezigo @ 6.01.2015 - 19:50)
Та да!
http://htmlparsing.com/php.html
http://simplehtmldom.sourceforge.net/
http://php.net/manual/en/domdocument.loadhtml.php

Использовал вторую ссылку.
Выдает следующие ошибки

Warning: file_get_contents(): http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/users2/d/denlam/domains/zayavochnik.ru/php_func/simple_html_dom.php on line 76

Warning: file_get_contents(http://www.ak-moto.ru): failed to open stream: no suitable wrapper could be found in /home/users2/d/denlam/domains/zayavochnik.ru/php_func/simple_html_dom.php on line 76

Fatal error: Call to a member function find() on boolean in /home/users2/d/denlam/domains/zayavochnik.ru/controllers/lk_editsite_page.controller.php on line 8
Dezigo
На вашем сервере должен быть установлен параметр allow_url_fopen=1, либо просто тогда делайте через curl.
Как в первом примере

<?php

# Use the Curl extension to query Google and get back a page of results
$url = "http://www.google.com";
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$html = curl_exec($ch);
curl_close($ch);

# Create a DOM parser object
$dom = new DOMDocument();

# Parse the HTML from Google.
# The @ before the method call suppresses any warnings that
# loadHTML might throw because of invalid HTML in the page.

@$dom->loadHTML($html);

# Iterate over all the <a> tags
foreach($dom->getElementsByTagName('a') as $link) {
# Show the <a href>
echo $link->getAttribute('href');
echo "<br />";
}
?>
Быстрый ответ:

 Графические смайлики |  Показывать подпись
Здесь расположена полная версия этой страницы.
Invision Power Board © 2001-2025 Invision Power Services, Inc.