simple-html-dom

How to get the absolute image URIs with SimpleHTMLDom [duplicate]

筅森魡賤 提交于 2019-12-06 15:12:44
This question already has answers here : How to extract complete sub links using Simple-HTML-DOM? (3 answers) Closed 6 years ago . I use simple_html_dom to get site's images. But sometimes, the image's link are not prefixed with the full domain URI, e.g. with http://example.com . They appear as something like images/_home-ss-21.jpg /_home-ss-22b.jpg ./_1249a7s.png or ../../../a19489s_20110412.jpeg. How to can I convert these URIs to absolute URIs including the protocol and domain information. <?php header('Content-type:text/html; charset=utf-8'); require_once 'simple_html_dom.php'; $v = 'http:

How to get iframe content from a remote page?

笑着哭i 提交于 2019-12-06 05:47:40
问题 I think PHP is useless, bacause iframe is inserted after php is executed, or am I wrong? So, the only solution I am aware of is to use Javascript/jQuery. E.g. this would work if the JS would be on the same page as a the iframe: <html> <head> <title></title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script> <script type="text/javascript"> $(function() { var myContent = $("#iFrame").contents().find("#myContent") }); </script> </head>

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

怎甘沉沦 提交于 2019-12-06 05:13:16
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') $file->find('/body/table[!class]/tr') $file->find('body table tr') Thanks for your advice. You could

How to get hover data(ajax) by any crawler php

﹥>﹥吖頭↗ 提交于 2019-12-06 03:01:56
I am crawling one website's data. I am able to whole content on a page. But some data on page comes after hover on some icons and shown as tooltips. So I require that data also. Is it possible with any crawler. I am using PHP and simplehtmldom for parsing/ crawling page. Hover data can't be obtained by any crawlers. Crawlers crawl the web page and gets whole data ( HTML page source ). It's view which we can view as soon as we hit URL. Hover need mouse moving action over HTML attribute on page i.e manual action. And currently no crawlers do actions for hovering and getting that data as per my

PHP Simple HTML DOM list of attributes

纵然是瞬间 提交于 2019-12-05 23:59:47
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 ). $el->attr is an associated array of tag=>value s You can use get_object_vars to get an associative array, and then loop over them.

get image src with simple-html-dom

倖福魔咒の 提交于 2019-12-05 20:18:49
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)->src; $item['details'] = $article->find('p', 0)->plaintext; Also i tried: $item['thumb'] = $article-

PHP simple html DOM remove all attributes from an html tag

跟風遠走 提交于 2019-12-05 14:37:11
$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="..." id = "..." style = "...">some text...</p> <font> <p class="..." id = "..." style = "...">some

Get text with PHP Simple HTML DOM Parser

谁说我不能喝 提交于 2019-12-04 21:56:54
i'm using PHP Simple HTML DOM Parser to get text from a webpage. The page i need to manipulate is something like: <html> <head> <title>title</title> <body> <div id="content"> <h1>HELLO</h1> Hello, world! </div> </body> </html> I need to get the h1 element and the text that has no tags. to get the h1 i use this code: $html = file_get_html("remote_page.html"); foreach($html->find('#content') as $text){ echo "H1: ".$text->find('h1', 0)->plaintext; } But the other text? I also tried this into the foreach but i get the full text: $text->plaintext; but it returned also the H1 tag... It looks like

Call to a member function find() on a non-object when inserting data using PHP mySQL simpleHTMLDOM

こ雲淡風輕ζ 提交于 2019-12-04 20:58:06
I have a script that parses certain elements from a webpage and stores them in a mysql db. Everything works fine until I try to split an element and store the resulting data into the db. Any ideas what might be wrong? Here's the page I'm parsing: http://www.ratemyprofessors.com/SelectTeacher.jsp?sid=953 Here's my code: <?php include('simple_html_dom.php'); //connect to db (code emitted) prof_List("http://www.ratemyprofessors.com/SelectTeacher.jsp?sid=953"); function prof_name($url) { // collect data echo $url; $data = new simple_html_dom(); $data->load_file($url); $profName = $data->find("//*[

Simple HTML Dom - find text between divs

笑着哭i 提交于 2019-12-04 17:59:38
I need to extract the text in between divs here ("The third of four...") - using Simple HTML Dom PHP library. I have tried everything I think! next_sibling() returns the comment, and next_sibling()->next_sibling() returns the <br/> tag. Ideally I would like to get all the text from the end of the first comment and to the next </div> tag. <div class="left"> Bla-bla.. <div class="float">Bla-bla... </div><!--/end of div.float--> <br />The third of four performances in the Society's Morning Melodies series features...<a href='index.php?page=tickets&month=20140201'><< Back to full event listing</a>