simple-html-dom

Simple-html-dom skips attributes

久未见 提交于 2019-12-08 06:40:55
问题 I am trying to parse html page of Google play and getting some information about apps. Simple-html-dom works perfect, but if page contains code without spaces, it completely ingnores attributes. For instance, I have html code: <div class="doc-banner-icon"><img itemprop="image"src="https://lh5.ggpht.com/iRd4LyD13y5hdAkpGRSb0PWwFrfU8qfswGNY2wWYw9z9hcyYfhU9uVbmhJ1uqU7vbfw=w124"/></div> As you can see, there is no any spaces between image and src , so simple-html-dom ignores src attribute and

Parsing drop down menu with php simple dom

◇◆丶佛笑我妖孽 提交于 2019-12-08 06:34:23
问题 I want to parse this drop down menu with php simple dom. <select name="example"> <option value="1">First example</option> <option value="2">Second example</option> <option value="3">Third example</option> </select> I need the values and the options for this drop down menu. 回答1: Like this : $dom = new DOMDocument("1.0", "utf-8"); $dom->formatOutput = true; $dom->loadXML($YOUR_XML_STRING); $xpath = new DOMXPath($dom); $res = $xpath->query('//option'); for ($i = 0; $i < $res->length; $i++) {

PHP Simple HTML DOM Parser how to get TR only from first table

让人想犯罪 __ 提交于 2019-12-07 23:53:08
问题 I have HTML code like following structure how in PHP to fetch TR only from first table using PHP Simple HTML DOM find method . <table width="100%" cellspacing="0" cellpadding="0" border="0" class="convertedTable"> <tbody> <tr> <td> <table width="100%" cellspacing="0" cellpadding="0" border="0"> <tbody> <tr> <td>...</td> </tr> </tbody> </table> </td> </tr> <tr> <td>Some text</td> </tr> <tr>...</tr> .... </tbody> </table> I tried these conditions, but doesn't work. ` $file->find('/body/table/tr

get image src with simple-html-dom

末鹿安然 提交于 2019-12-07 16:37:39
问题 hello guys i am using simple_html_dom.php to fetch some data but i cannot grab image src. My html is: <div class="image"> <a href="http://example.com/post/367327/oikogeneiarxhs" title="Some Title"> <img class="lazy" src="http://example.com/storage/photos/myimage.jpg" data-original="http://example.com/storage/photos/myimage.jpg" alt="Some Title" style="display: inline;"></a> </div> My code is: $item['title'] = $article->find('.title', 0)->plaintext; $item['thumb'] = $article->find('.lazy', 0)-

PHP Simple HTML DOM list of attributes

对着背影说爱祢 提交于 2019-12-07 14:43:58
问题 The simple_html_dom library is great for getting known attributes, but is there a way to get a list of all the attributes for an element? For example, if I have: <div id="test" custom1="custom" custom2="custom"> I can easily get the id : $el = $html->find('div'); $id = $el->id; But, is it possible to get custom1 and custom2 if they are not known ahead of time? Ideally, the solution would produce an array of the NVP 's for all attributes ( id , custom1 , custom2 ). 回答1: $el->attr is an

SimpleHTMLDom: Call to a member function find() on array

杀马特。学长 韩版系。学妹 提交于 2019-12-07 13:31:01
问题 So i want to loop trough specific TD 's in a LARGE html page. I'm using simplehtmldom in order to achieve that. The problem is that i cant make it work without putting every step in a foreach. Here is my php include('../inc/simple_html_dom.php'); $html = file_get_html("http://www.bjork-family.com/f43-london-stories"); // I just put the dom of pagebody into TEST $test = $html->find('#page-body'); foreach($test->find('img') as $element) { echo "<img src='" . $element->src . "'/>" . '<br>'; } i

Reverse image scraping with PHP

萝らか妹 提交于 2019-12-07 11:40:55
问题 I need to fetch some images using google Reverse image search which is not supported by the API, but thankfully, you can query google with a direct link to the image and it still shows results, so: $googleURL = "https://www.google.com/searchbyimage?&image_url=".$imageURL; echo $googleURL; Output: https://www.google.com.au/search?tbs=sbi:AMhZZiu9rNRW4ETWGjN9XYQKsa21UHM7j_1TjMjXvYyNH1knVTyMGZGNmS2yme4CsQb0T7UViTyNrG4e8u_1xLY-dZCU16wkfdUakeY7idDwyMge78nT--Grpll4t9

Parsing drop down menu with php simple dom

寵の児 提交于 2019-12-07 10:45:29
I want to parse this drop down menu with php simple dom. <select name="example"> <option value="1">First example</option> <option value="2">Second example</option> <option value="3">Third example</option> </select> I need the values and the options for this drop down menu. Like this : $dom = new DOMDocument("1.0", "utf-8"); $dom->formatOutput = true; $dom->loadXML($YOUR_XML_STRING); $xpath = new DOMXPath($dom); $res = $xpath->query('//option'); for ($i = 0; $i < $res->length; $i++) { $node = $res->item($i); $value = $node->getAttribute('value'); $content = $node->nodeValue; } With PHP simple

PHP simple html DOM remove all attributes from an html tag

你说的曾经没有我的故事 提交于 2019-12-07 07:07:19
问题 $html = file_get_html('page.php'); foreach($html->find('p') as $tag_name) { $attr = substr($tag_name->outertext,2,strpos($tag_name->outertext, ">")-2); $tag_name->outertext = str_replace($attr, "", $tag_name->outertext); } echo $html->innertext; Above is the code I wrote to take what's inside all <p> tags in my html page and remove them. My html code is similar to this : <p class="..." id = "..." style = "...">some text...</p> <p class="..." id = "..." style = "...">some text...</p> <p class=

Simple html dom - how get dt/dd elements to array? [duplicate]

Deadly 提交于 2019-12-07 00:14:24
This question already has answers here : Closed 7 years ago . Possible Duplicate: Get data only from html table used preg_match_all in php HTML: <div class="table"> <dl> <dt>ID:</dt> <dd>632991</dd> <dt>Type:</dt> <dd>NEW</dd> <dt>Body Type:</dt> <dd>Compact</dd> </dl> </div> What's is the best way to get this using simple_html_dom in PHP: PHP: $option = array( 'id' => 632991, 'Type' => 'NEW', 'Body Type' => 'Compact' ); René Höhle You could use XPath: Getting DOM elements by classname Get Element ByTag Name Using PHP to get DOM Element Here are a lot of posts on Stackoverflow. Use the search