simple-html-dom

simple htmldom parser not parsing microdata

混江龙づ霸主 提交于 2019-12-02 12:04:00
I am trying to parse the price $30 from the below microdata : <div itemprop="offers" itemscope="" itemtype="http://schema.org/Offer"> <span itemprop="price"><strong>$30.00</strong></span></div> here is the code I am trying to,but its throwing error Fatal error: Call to a member function find() $url="http://somesite.com"; $html=file_get_html($url); foreach($html->find('span[itemprop=price]') as $price) echo $price; any suggestions, where its going wrong?, or not sure how to parse with You forgot calling the str_get_html(YOUR_HTML) function? or file_get_html(YOUR_FILE) If you didn't forget it,

simplehtmldom 500 error

匆匆过客 提交于 2019-12-02 08:53:46
问题 I saw that there are a lot of topics on simplehtmldom, but no one's problem seems to be mine- specifically, that it just 500s, even on the examples provided. I've found that I can include the file without an error, but if I then try to use file_get_html, it 500s. The only thing I found in the manual about installation is a possible problem with allow_fopen_url, which I do. Something I'm missing? 回答1: Seems like too long since you asked this question, but since I came across this trying to

simplehtmldom 500 error

和自甴很熟 提交于 2019-12-02 06:52:23
I saw that there are a lot of topics on simplehtmldom, but no one's problem seems to be mine- specifically, that it just 500s, even on the examples provided. I've found that I can include the file without an error, but if I then try to use file_get_html, it 500s. The only thing I found in the manual about installation is a possible problem with allow_fopen_url, which I do. Something I'm missing? Brett James Seems like too long since you asked this question, but since I came across this trying to solve this problem myself, I thought I'd post what worked for me. I solved this problem by changing

simple html dom - space in class name

≡放荡痞女 提交于 2019-12-02 06:26:04
问题 I'm using PHP Simple HTML DOM to get element from a source code of a site (not mine) and when I find a ul class that is called "board List",this is not found.I think it might be a problem of space but I don't know how to solve it. this is a piece of php code: $html = str_get_html($result['content']); //get the html of the site $board = $html->find('.board List'); // Find all element which class=board List,but in my case it doesn't work,with other class name it works and this is a piece of

how to add a custom attributes with PHP Simple HTML DOM Parser

喜夏-厌秋 提交于 2019-12-02 05:36:28
问题 I am working with a project that require the use of PHP Simple HTML Dom Parser, and I need a way to add a custom attribute to a number of elements based on class name. I am able to loop through the elements with a foreach loop, and it would be easy to set a standard attribute such as href, but I can't find a way to add a custom attribute. The closest I can guess is something like: foreach($html -> find(".myelems") as $element) { $element->myattr="customvalue"; } but this doesn't work. I have

How to get the Previous Sibling name

匆匆过客 提交于 2019-12-02 04:15:28
问题 I need to get the name of the previous sibling . to keep it simple i have some sample code <html> <head> <script type="text/javascript"> function myFunction() { var itm=document.getElementById("item2"); alert(itm.previousSibling.name); } </script> </head> <body> <p name='pn'>paragraph</p> <button id='item2' onclick="myFunction()">Try it</button> </body> </html> Edit: <table id="sort"> <tr name="nodrag nodrop"> <td colspan=3><strong><a style="cursor:pointer;" class="toggle">Group 1</a></strong

How to imitate child selector with Simple HTML DOM?

对着背影说爱祢 提交于 2019-12-02 03:46:23
问题 Fellas! I have one nasty page to parse but can't figure out how to extract correct data blocks from it using Simple HTML DOM, because it has no CSS child selector support. HTML: <ul class="ul-block"> <li>xxx</li> <li>xxx</li> <li> <ul> <li>xxx2</li> </ul> </ul> How would I extract (direct) child li elements of parent ul.ul-block ? The $node->find('ul[class=ul-block] > li'); doesn't work and $node->find('ul[class=ul-block] li'); ofc finds also nested descandant li elements :( 回答1: Simple

How to imitate child selector with Simple HTML DOM?

我与影子孤独终老i 提交于 2019-12-02 03:35:41
Fellas! I have one nasty page to parse but can't figure out how to extract correct data blocks from it using Simple HTML DOM , because it has no CSS child selector support. HTML: <ul class="ul-block"> <li>xxx</li> <li>xxx</li> <li> <ul> <li>xxx2</li> </ul> </ul> How would I extract (direct) child li elements of parent ul.ul-block ? The $node->find('ul[class=ul-block] > li'); doesn't work and $node->find('ul[class=ul-block] li'); ofc finds also nested descandant li elements :( Simple example with php DOM : $dom = new DomDocument; $dom->loadHtml(' <ul class="ul-block"> <li>a</li> <li>b</li> <li>

How to get the Previous Sibling name

£可爱£侵袭症+ 提交于 2019-12-02 02:26:25
I need to get the name of the previous sibling . to keep it simple i have some sample code <html> <head> <script type="text/javascript"> function myFunction() { var itm=document.getElementById("item2"); alert(itm.previousSibling.name); } </script> </head> <body> <p name='pn'>paragraph</p> <button id='item2' onclick="myFunction()">Try it</button> </body> </html> Edit: <table id="sort"> <tr name="nodrag nodrop"> <td colspan=3><strong><a style="cursor:pointer;" class="toggle">Group 1</a></strong> </td> <td style="text-align: right;"><a class="button3" href="#" ><span> Edit </span></a> <a class=

how to add a custom attributes with PHP Simple HTML DOM Parser

断了今生、忘了曾经 提交于 2019-12-02 01:38:50
I am working with a project that require the use of PHP Simple HTML Dom Parser, and I need a way to add a custom attribute to a number of elements based on class name. I am able to loop through the elements with a foreach loop, and it would be easy to set a standard attribute such as href, but I can't find a way to add a custom attribute. The closest I can guess is something like: foreach($html -> find(".myelems") as $element) { $element->myattr="customvalue"; } but this doesn't work. I have seen a number of other questions on similar topics, but they all suggest using an alternative method