simple-html-dom

Simple HTML Dom Parser: How to insert to elements

浪尽此生 提交于 2019-12-04 12:27:17
问题 I am trying to insert (append) into an element ... "body" specifically. I am able to do this this way at the moment: $var = "some JS stuff"; $e = $htmlDOM->find("body", 0); $e->outertext = '<body>' . $e->innertext . $var . '</body>'; My issue is that this fixes <body> but the actual html might have js or id etc attached to <body> and I will like to maintain that if it is the case. The docs don't seem to show a method for this. Is it possible? 回答1: After looking at the source code, I found

How to get iframe content from a remote page?

落花浮王杯 提交于 2019-12-04 10:48:31
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> <body> <iframe src="mifile.html" id="iFrame" style="width:200px;height:70px;border:dotted 1px red"

simple html dom: how get a tag without certain attribute

做~自己de王妃 提交于 2019-12-04 10:09:40
I want to get the tags with "class" attribute equal to "someclass" but only those tags that hasn't defined the attribute "id". I tried the following (based on this answer) but didn't work: $html->find('.someclass[id!=*]'); Note: I'm using Simple HTML DOM class and in the basic documentation that they give, I didn't find what I need. Simple HTML DOM class does not support CSS3 pseudo classes which is required for negative attribute matching. It is simple to work around the limitation without much trouble. $nodes = array_filter($html->find('.something'), function($node){return empty($node->id);}

Simple HTML DOM spaces into class

两盒软妹~` 提交于 2019-12-04 04:59:18
问题 I'm using Simple HTML DOM to get elements from a website, but when class attribute has spaces, I don't get anything. Source HTML from betaexplorer.com <table id="table-type-2" class="stats-table stats-main table-2"> <tbody> <tr class="odd glib-participant-ppjDR086" data-def-order="0"> <td class="rank col_rank no" title="">1.</td> <td class="participant_name col_participant_name col_name"><span class="team_name_span"><a onclick="javascript:getUrlByWinType('/soccer/england/premier-league

Character Encoding issue with PHP Simple HTML DOM Parser

杀马特。学长 韩版系。学妹 提交于 2019-12-03 22:25:15
问题 I am using PHP Simple HTML DOM Parser http://simplehtmldom.sourceforge.net/ to fetch data like Page Title, Meta Description and Meta Tags from other domains and then insert it into database. But I have some issues with encoding. The problem is that I do not get correct characters from those website which is not in English Language. Below is the code: <?php require 'init.php'; $curl = new curl(); $html = new simple_html_dom(); $page = $_GET['page']; $curl_output = $curl->getPage($page); $html-

Simple HTML Dom Parser: How to insert to elements

老子叫甜甜 提交于 2019-12-03 08:53:27
I am trying to insert (append) into an element ... "body" specifically. I am able to do this this way at the moment: $var = "some JS stuff"; $e = $htmlDOM->find("body", 0); $e->outertext = '<body>' . $e->innertext . $var . '</body>'; My issue is that this fixes <body> but the actual html might have js or id etc attached to <body> and I will like to maintain that if it is the case. The docs don't seem to show a method for this. Is it possible? After looking at the source code, I found that the way to go about it is to use $var = "some JS stuff"; $e = $htmlDOM->find("body", 0); $e->outertext =

PHP Fatal error: Call to a member function find() on a non-object however my function work

时间秒杀一切 提交于 2019-12-03 07:28:30
I am getting this error on Line 71 of my code, however the function of this line is executed correctly and it does what I expect it to do. However, I noticed that my error log is full of these lines: [09-Dec-2013 14:54:02 UTC] PHP Fatal error: Call to a member function find() on a non-object in /home/sportve/public_html/open_event_common.php on line 71 What I have checked for: simple_html_dom_parser is already included and this function that Line 71 intend to do is working. Here is Line 71 of my code: $content->find('a.openevent', 0)->innertext = ''; so its confusing as to what is causing this

php , simple_html_dom.php, get selected option

巧了我就是萌 提交于 2019-12-02 19:13:15
问题 I have a html block like this : $localurl = ' <select name="cCountry" id="cCountry" style="width:200" tabindex="5"> <option value="251">Ascension Island</option> <option selected="selected" value="14">Australia</option> <option value="13">Austria</option> '; I'm trying to extract the selected value in this case "Australia" using simple_html_dom ( http://simplehtmldom.sourceforge.net/ ). So far I have build a function but is not working : //extract the selected value function getValue_selected

Get products from e-shop using simple dom parser and pagination

断了今生、忘了曾经 提交于 2019-12-02 15:21:22
问题 I want to parse some products link, name and price. Here's my code: Having some trouble parsing, because I don't know how to get product link's and name's.Price is ok, I get it. And pagination not working as well <h2>Telefonai Pigu</h2> </br> <?php include_once('simple_html_dom.php'); $url = "http://pigu.lt/foto_gsm_mp3/mobilieji_telefonai/"; // Start from the main page $nextLink = $url; // Loop on each next Link as long as it exsists while ($nextLink) { echo "<hr>nextLink: $nextLink<br>"; /

How to scrape ajax calls in PHP

那年仲夏 提交于 2019-12-02 13:04:55
Please let me know is it possible to scrap some info after ajax loaded with PHP? I had only used SIMPLE_HTML_DOM for static pages. Thanks for advice. ductiletoaster Scraping the entire site Scraping Dynamic content requires you to actually render the page. A PHP server-side scraper will just do a simple file_get_contents or similar. Most server based scrappers wont render the entire site and therefore don't load the dynamic content generated by the Ajax calls. Something like Selenium should do the trick. Quick google search found numerous examples on how to set it up. Here is one Scraping JUST