simple-html-dom

How can I speed this up?

☆樱花仙子☆ 提交于 2020-01-06 14:59:17
问题 I have a script which I think is pretty basic scraping, call it what you will, but it takes on average at least 6 seconds...is it possible to speed it up? The $date variables are only there for timing the code and don't add anything significant to the time it takes. I have set two timing markers and each is approx 3 seconds between. Example URL below for testing $date = date('m/d/Y h:i:s a', time()); echo "start of timing $date<br /><br />"; include('simple_html_dom.php'); function

How to get all children tags from XML(fast info document) in PHP

試著忘記壹切 提交于 2020-01-06 07:02:48
问题 I have problem in code when i parse the XML to Array.it returns some tags and not the complete tags.I want to get all tags inside in soap response.I have xml file.and upload this file. Here is data.txt file below: <?xml version="1.0" encoding="utf-8"?> <soapenv:Envelope xmlns:soapenv="<a rel="nofollow" class="external free" href="http://schemas.xmlsoap.org/soap/envelope/">http://schemas.xmlsoap.org/soap/envelope/</a>" xmlns="urn:enterprise.soap.sforce.com"> <soapenv:Body> <retrieveResponse>

How to get all children tags from XML(fast info document) in PHP

给你一囗甜甜゛ 提交于 2020-01-06 07:02:12
问题 I have problem in code when i parse the XML to Array.it returns some tags and not the complete tags.I want to get all tags inside in soap response.I have xml file.and upload this file. Here is data.txt file below: <?xml version="1.0" encoding="utf-8"?> <soapenv:Envelope xmlns:soapenv="<a rel="nofollow" class="external free" href="http://schemas.xmlsoap.org/soap/envelope/">http://schemas.xmlsoap.org/soap/envelope/</a>" xmlns="urn:enterprise.soap.sforce.com"> <soapenv:Body> <retrieveResponse>

PHP:Simple Dom Parser Find Nth Element Class Exist

余生长醉 提交于 2020-01-05 10:07:30
问题 I am using the PHP Simple DOM Parser for parsing the HTML Page, Now i am lacking in particular point of how to find the nth element class should be a particular class For Example: <table> <tr> <th class="h1">ONE</td> <th class="h2">TWO</td> <th class="h3">THREE</td> </tr> <tr> <td class="one">Apple</td> <td class="two">Orange</td> <td class="null">N/A</td> </tr> <tr> <td class="one">Apple</td> <td class="null">N/A</td> <td class="three">Banana</td> </tr> </table> The table looks something

php code to extract all text links not image link

佐手、 提交于 2020-01-05 08:52:27
问题 I want to extract all text link from a webpage using simplehtmldom class. But i don't want image links. <? foreach($html->find('a[href]') as $element) echo $element->href . '<br>'; ?> above code shows all anchor links containing href attribute. <a href="/contact">contact</a> <a href="/about">about</a> <a herf="/home"><img src="logo.png" /><a> i want only /contact and /about not /home because it contains image instead of text 回答1: <?php foreach($html->find('a[href]') as $element) { if (empty

Retrieve data from the first td in every tr

China☆狼群 提交于 2020-01-05 06:59:50
问题 I'm scraping a page which contains of a table with several tr's. Inside every tr there's four td's, and I want to get the data from the first of these td's. Below is the code I've tried so far, but it grabs all the td's. How can I accomplish what I want? ... $html = new simple_html_dom(); $html = file_get_html($url); foreach($html->find('table tr') as $row) { foreach($row->find('td', 0) as $cell) { echo $cell; } } 回答1: Think about why you're using the second foreach when you actually only

PHP: Simple HTML DOM Parser - multiple attributes in find()?

坚强是说给别人听的谎言 提交于 2020-01-05 03:00:28
问题 I'm using Simple HTML DOM Parser but can't figure out how to get elements that have 2 or more matching attributes. Sadly, to get the first 2 divs, this doesn't work: $html = "<div title='test a' class='a' >test a</div> <div title='test b' class='b' >test b</div> <div title='test c' class='c' >test c</div>"; $htmldom = str_get_html($html); $ab = $htmldom->find("div[class=a][class=b]"); Is it even possible? 回答1: You can find all divs with either class a or class b by invoking: $ab = $htmldom-

Fatal error: Allowed memory size of 33554432 bytes exhausted [duplicate]

冷暖自知 提交于 2020-01-04 02:12:27
问题 This question already has answers here : How do you parse and process HTML/XML in PHP? (30 answers) Closed 6 years ago . $html = file_get_html('http://www.oddsshark.com/mlb/odds'); echo $html; When ehcoed, the error message in the title of this question appears? I've had problems that are similar to this before. In all cases, I didn't actually need to increase the memoery in php.ini. Rather, there was a missing curly bracket that was needed to close a loop. This page that I'm requesting via

Php Simple Html Dom Parser can't get content on pagination

孤者浪人 提交于 2020-01-03 05:06:26
问题 Hi i'm a beginner in using simple_html_dom . i'm trying to fetch list of href's from list of posts from this sample website having pagination using below code. <?php include('simple_html_dom.php'); $html = file_get_html('http://www.themelock.com/wordpress/elegantthemes/'); function getArticles($page) { global $articles; $html = new simple_html_dom(); $html->load_file($page); $items = $html->find('h2[class=post-title]'); foreach($items as $post) { $articles[] = array($post->children(0)->href);

Php Simple Html Dom Parser can't get content on pagination

故事扮演 提交于 2020-01-03 05:05:08
问题 Hi i'm a beginner in using simple_html_dom . i'm trying to fetch list of href's from list of posts from this sample website having pagination using below code. <?php include('simple_html_dom.php'); $html = file_get_html('http://www.themelock.com/wordpress/elegantthemes/'); function getArticles($page) { global $articles; $html = new simple_html_dom(); $html->load_file($page); $items = $html->find('h2[class=post-title]'); foreach($items as $post) { $articles[] = array($post->children(0)->href);