I am creating a system in which I will need to capture the contents of a webpage using PHP and then parse it to extract specific tables, etc. Is there an easy way to do this using jQuery or would it be best to write a PHP function to retrieve data?
jQuery has nothing to do with PHP and cannot be run without a browser, so you're out of luck there.
However, there is phpQuery that allows parsing the DOM with jQuery selectors!
php php DOM xpath:
$dom = new DOMDocument(); @$dom->loadHTML($html); $x = new DOMXPath($dom); // grab all tables with id of foo foreach($x->query("//table[@id='foo']") as $node) { // here is the html echo $node->c14n(); // grab the containing text echo $node->textContent() }
DOM, PHP http://php.net/manual/en/book.dom.php
. jQuery JavaScript, , JavaScript-.
HTML XML, , HTML XHTML.
http://sourceforge.net/projects/simplehtmldom/
:
// Create DOM from URL or file $html = file_get_html('http://www.google.com/'); // Find all images foreach($html->find('img') as $element) echo $element->src . '<br>'; // Find all links foreach($html->find('a') as $element) echo $element->href . '<br>';
php, , curl, dom xpath.
, .
Source: https://habr.com/ru/post/1772924/More articles:Entity Framework 4 Save and Cancel - .netНевозможно создать экземпляр класса: org.jnp.interfaces.NamingContextFactory - javaIn Eclipse, how do you find methods that you defined but didn't use / call anywhere in the application? - javahttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1772922/using-properties-to-access-ivars-in-init&usg=ALkJrhhUSNOX7LoG5xDXZUQhSOrdIYKpUAПоддерживать пароли членства ASP.Net во время смены ключа машины - asp.netOpenGL, применяя текстуру от изображения к isosurface - c++How to visualize a 3d scene using surfing - matlabПочему мой или выражение не работает, С++? - c++Структурирование классов - javaHow to apply the Ford-Fulkerson algorithm to a graph to find the maximum stream in a streaming network? - algorithmAll Articles