Opening several javascript link from page - php

I am using "fabpot/goutte": "^3.2" and use PHP 7.3.5.
I am trying to access the following page and click the link - https://www.forexfactory.com/calendar.php?month=nov.2019 - to open the below box:
I tried to filter all this links, however no links are found:
$subCrawler->filter('td.calendar__cell.calendar__detail.detail > a')->each(function ($node) {
$link = $node->link();
print $link ."\n";
print $node->text() ."\n";
});
Any suggestions how to click the link with goutte and get the source text and usual effect text?

Using Goutte:
<?php
require 'vendor/autoload.php';
use Goutte\Client;
use Symfony\Component\DomCrawler\Crawler;
$x = 1;
$LIMIT = 20;
$client = new Client();
$crawler = $client->request('GET', 'https://www.forexfactory.com/calendar.php?month=nov.2019');
$resArray = array();
$TEMP = array();
$crawler->filter('.calendar_row')->each(function ($node) {
global $x;
global $LIMIT;
global $resArray;
global $TEMP;
$x++;
$EVENTID = $node->attr('data-eventid');
$API_RESPONSE = file_get_contents('https://www.forexfactory.com/flex.php?do=ajax&contentType=Content&flex=calendar_mainCal&details='.$EVENTID);
$API_RESPONSE = str_replace("<![CDATA[","",$API_RESPONSE);
$API_RESPONSE = str_replace("]]>","",$API_RESPONSE);
$html = <<<HTML
<!DOCTYPE html>
<html>
<body>
$API_RESPONSE
</body>
</html>
HTML;
$subcrawler = new Crawler($html);
$subcrawler->filter('.calendarspecs__spec')->each(function ($LEFT_TD) {
global $resArray;
global $TEMP;
$LEFT_TD_INNER_TEXT = trim($LEFT_TD->text());
if($LEFT_TD_INNER_TEXT == "Source"){
$TEMP = array();
$LEFT_TD->nextAll()->filter('a')->each(function ($LINK) {
global $TEMP;
array_push($TEMP,$LINK->text(),$LINK->attr('href'));
});
$EVENT['sourceTEXT'] = $TEMP[0];
$EVENT['sourceURL'] = $TEMP[1];
$EVENT['latestURL'] = $TEMP[3];
array_push($resArray,$EVENT);
}
});
if($x>$LIMIT){
echo "<pre>"; var_dump($resArray); echo "</pre>";
exit;
}
});
Using Simple HTML DOM. You can get it from here.
<?php
include('simple_html_dom.php');
$html = file_get_html('https://www.forexfactory.com/calendar.php?month=nov.2019');
$x = 1;
$LIMIT = 10;
foreach($html->find('.calendar_row') as $e){
$x++;
$EVENTID = $e->attr['data-eventid'];
$EVENTNAME = $e->find('.event')[0]->find('div')[0]->innertext;
echo "<h4>".$EVENTNAME."</h4><br>";
$API_RESPONSE = file_get_html('https://www.forexfactory.com/flex.php?do=ajax&contentType=Content&flex=calendar_mainCal&details='.$EVENTID);
$API_RESPONSE = str_replace("<![CDATA[","",$API_RESPONSE);
$API_RESPONSE = str_replace("]]>","",$API_RESPONSE);
$API_RESPONSE = str_get_html($API_RESPONSE);
foreach($API_RESPONSE->find('.calendarspecs__spec') as $LEFT_TD){
$LEFT_TD_INNER_TEXT = trim($LEFT_TD->innertext);
if($LEFT_TD_INNER_TEXT == "Source" || $LEFT_TD_INNER_TEXT == "Usual Effect"){
echo $LEFT_TD_INNER_TEXT.": ".$LEFT_TD->next_sibling()->innertext."<br>";
}
}
if($x>$LIMIT)
break;
echo "<hr>";
}
Screenshot(Goutte):
Screenshot(SIMPLE HTML DOM):

Related

Return an iframe view from a controller function

I am new to Laravel. Here is the function I have in SmartpayS controller. I want to return this url in an iframe.
$url = $item->nodeValue;
function processSmartpaySPayment($paymentType = false, $totalAmount = 0, $currency = false, $payingUserId = false, $quoteId = false, $clubMembershipQuotationId = false)
{
$callBackUrl = 'smartpays-payment/response/'.$quoteId;
if (!empty($payingUserId)) {
$customerDetails = $this->customerRepo->getCustomerDetails($payingUserId);
} else {
return false;
}
$testString = $this->smartPaySRepo->createSmartpaySPayment($paymentType, env('ENTERPRISE_ID'), 'DE02', 'ECommerce',env('AUTH_TYPE'), $totalAmount, $customerDetails, $currency, $callBackUrl, $quoteId, $clubMembershipQuotationId, env('STORE_RESULT_PAGE') );
$dom = new \DOMDocument();
$dom->formatOutput = TRUE;
$dom->preserveWhiteSpace = FALSE;
$dom->loadXml($testString);
foreach ($dom->getElementsByTagName('redirectURL') as $item) {
$url = $item->nodeValue;
}
return redirect($url);
}
----------
**********iframe is in the view.(paymentload.blade.php)*************
<iframe src="<?php echo $url; ?>" width="600px" height ="800px" ></iframe>
I tried to load the iframe. But it says "Undefined variable: url"
Help me to return the iframe which is in the View from the controller function.
try this
$url = '';
foreach ($dom->getElementsByTagName('redirectURL') as $item) {
$url = $item->nodeValue;
}
return redirect($url);
i think you are adding $item->nodeValue each time so you should use like this
$url = '';
foreach ($dom->getElementsByTagName('redirectURL') as $item) {
$url += $item->nodeValue; // check i have added + here
}
return redirect($url);

recursive PHP function return Allowed memory size exhausted

i'm working on a small DOM project, to get dynamic links and static links. but my function take a lot of time to be executed and return an error as you can see
allowed memory size of bytes exhausted
this is my PHP code:
public $domain_name = 'www.example.com';
public function dynamic_url2($url = "http://www.example.com"){
$pages = array();
$html = file_get_html($url);
foreach($html->find('a') as $page){
if(valid_url($page->href)){
$parse_page = parse_url($page->href);
if($parse_page['host'] == $this->domain_name){
if(!in_array($page->href, $pages)){
$pages[] = $page->href;
if(array_key_exists('query', $parse_page))
echo 'contain dynamic parameters : '. $page->href.'<br>';
else
echo 'not dynamic : '. $page->href.'<br>';
}
return $this->dynamic_url2($page->href);
}
}
}
}
is my function correct ? how can i optimize it ?
thanks
Apart from some minor adjustments that I made while testing, you only need to make $pages modifiable (via &$pages in the function declaration) and pass the $pages array with every recursive call.
public $domain_name = 'https://www.example.html';
public function dynamic_url2($url, &$pages = []){
//echo "<div>Crawling $url</div>";
$dom = new DOMDocument;
libxml_use_internal_errors(true); // for malformed html warning suppression
$dom->loadHTML(file_get_contents($url)); // this doesn't account for relative urls
$xpath = new DOMXPath($dom);
foreach ($xpath->query("//a") as $a) {
$href = $a->getAttribute('href');
//echo "<div>Found $href # $url</div>";
if (valid_url($href)) {
$parsed = parse_url($href);
if ($parsed['host'] == $this->domain_name && !in_array($href, $pages)) {
$pages[] = $href;
//echo "<div>$href is " , (array_key_exists('query', $parsed) ? '' : 'not ') , 'dynamic</div>';
$this->dynamic_url2($href, $pages);
} else {
//echo "<div>Ignored url: $href</div>";
}
} else {
//echo "<div>Invalid url: $href</div>";
}
}
return $pages;
}
var_export($this->dynamic_url2($this->domain_name));

SimpleXMLReader not working properly

I've been trying to use SimpleXMLReader
to retrieve data from the following XML structure:
<boutique>
<produto num="228122907">
<id_produto><![CDATA[70427038]]></id_produto>
<nome><![CDATA[Solução Antirrugas - Kit]]></nome>
<descricao><![CDATA[A melhor combinação do Pegolift com Vitamina C elevada ao extremo e as pluri funções do Pluri-Active. Experimente estes agentes.]]></descricao>
</produto>
</boutique>
But I'm only being able to retrieve and echo the "num" node's value.
Like this result I get something like this:
/boutique/produto: 228122907 = 0;
/boutique/produto: 285823820 = 0;
/boutique/produto: 285823824 = 0;
/boutique/produto: 285823825 = 0;
/boutique/produto: 285823826 = 0;
/boutique/produto: 285823827 = 0;
It doesn't matter what I change, I can't seem to get the node <nome>value for example.
I'm using this software because I'm dealing with a pretty big XML file.
Download the XML here: http://v2.afilio.com.br/aff/aff_get_boutique.php?boutiqueid=37930-895987&token=53e355b0a09ea0.74300807&progid=1010&format=XML
Get SimpleXMLReader here: https://github.com/dkrnl/SimpleXMLReader
My code is as follows:
<?php
header ("Content-type: text/html, charset=utf-8;");
require_once dirname(__FILE__). "/simplexmlreader.php";
class ExampleXmlReader1 extends SimpleXMLReader
{
public function __construct()
{
// by node name
$this->registerCallback("nome", array($this, "callbackPrice"));
// by xpath<br />
///////////////////// Nesta parte não mexe
$this->registerCallback("/boutique/produto", array($this, "callbackRest"));
}
protected function callbackPrice($reader)
{
$xml = $reader->expandSimpleXml();
$attributes = $xml->attributes();
$ref = (string) $attributes->{"num"};
if ($ref) {
$price = floatval((string)$xml);
$xpath = $this->currentXpath();
echo "$xpath: $ref = $price;\n";
}
return true;
}
protected function callbackRest($reader)
{
$xml = $reader->expandSimpleXml();
$attributes = $xml->attributes();
$ref = (string) $attributes->{"num"};
if ($ref) {
$rest = floatval((string) $xml);
$xpath = $this->currentXpath();
echo "$xpath: $ref = $rest;\n";
}
return true;
}
}
echo "<pre>";
$file = dirname(__FILE__) . "/boutique.xml";
$reader = new ExampleXmlReader1;
$reader->open($file);
$reader->parse();
$reader->close();

Using ZeroMQ (PHP-ZMQ) for loop operations

I'm trying to use heavy resource content loop operation with ZeroMQ (PHP-ZMQ) via tcp protocol.
I've got below code so far:
class SJB_Miscellaneous_SendNotifications extends SJB_Function
{
public function execute()
{
try{
set_time_limit(0);
$i18n = SJB_I18N::getInstance();
$lang = $i18n->getLanguageData($i18n->getCurrentLanguage());
$current_date = strftime($lang['date_format'], time());
// Send Search Notifications
$saved_searches = SJB_SavedSearches::getAutoNotifySavedSearches();
// echo "<pre>"; print_r($saved_searches); echo "</pre>"; exit;
$listing = new SJB_Listing();
$notified_saved_searches_sid = array();
$notificationsLimit = (int) SJB_Settings::getSettingByName('num_of_listings_sent_in_email_alerts');
/* ZeroMQ implementation */
$queue = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REQ, "MySock1");
$queue->connect("tcp://127.0.0.1:5555");
/* Assign socket 1 to the queue, send and receive */
$time = time();
$queue->send(json_encode($saved_searches));
// echo $queue->recv();
// exit;
$count = 1;
// array_shift($saved_searches);
$server = new ZMQSocket(new ZMQContext(), ZMQ::SOCKET_REP);
$server->bind("tcp://127.0.0.1:5555");
$msg = $server->recv();
$saved_searches = json_decode($msg, true);
// echo "<pre>"; var_dump($saved_searches); echo "</pre>";
// exit;
foreach ($saved_searches as $saved_search) {
$searcher = new SJB_ListingSearcher();
$listing->addActivationDateProperty();
$search_data = unserialize($saved_search['data']);
$search_data['active']['equal'] = 1;
$datearr = explode('-', $saved_search['last_send']);
$saved_search['last_send'] = strftime($lang['date_format'], mktime(0, 0, 0, $datearr[1], $datearr[2], $datearr[0]));
$search_data['activation_date']['not_less'] = $saved_search['last_send'];
$search_data['activation_date']['not_more'] = $current_date;
$listing_type_sid = 0;
if ($search_data['listing_type']['equal']) {
$listing_type_id = $search_data['listing_type']['equal'];
$listing_type_sid = SJB_ListingTypeManager::getListingTypeSIDByID($listing_type_id);
if (SJB_ListingTypeManager::getWaitApproveSettingByListingType($listing_type_sid))
$search_data['status']['equal'] = 'approved';
}
// echo "<pre>"; echo $saved_search['user_sid']; print_r($listing_type_id); echo "</pre>"; exit;
$id_alias_info = $listing->addIDProperty();
$username_alias_info = $listing->addUsernameProperty();
$listing_type_id_info = $listing->addListingTypeIDProperty();
$aliases = new SJB_PropertyAliases();
$aliases->addAlias($id_alias_info);
$aliases->addAlias($username_alias_info);
$aliases->addAlias($listing_type_id_info);
$search_data['access_type'] = array(
'accessible' => $saved_search['user_sid'],
);
$criteria = SJB_SearchFormBuilder::extractCriteriaFromRequestData($search_data, $listing);
$searcher->found_object_sids = array();
$searcher->setLimit($notificationsLimit);
$sorting_fields = array('CityRegion' => 'ASC');
$found_listings_ids = $searcher->getObjectsSIDsByCriteria($criteria, $aliases, $sorting_fields);
// echo "<pre>"; var_dump($found_listings_ids); echo "</pre>";
if (count($found_listings_ids)) {
$saved_search['activation_date'] = $saved_search['last_send'];
if (SJB_Notifications::sendUserNewListingsFoundLetter($found_listings_ids, $saved_search['user_sid'], $saved_search, $listing_type_sid)) {
SJB_Statistics::addStatistics('sentAlert', $listing_type_sid, $saved_search['sid']);
SJB_DB::query('UPDATE `saved_searches` SET `last_send` = CURDATE() WHERE `sid` = ?n', $saved_search['sid']);
}
$notified_saved_searches_sid[] = $saved_search['sid'];
}
echo nl2br($count."\n");
$count++;
}
// To be entered from task_scheduler.php
$expired_contracts_id = null; $expired_listings_id = null;
$template_processor = SJB_System::getTemplateProcessor();
$template_processor->assign('expired_listings_id', null);
$template_processor->assign('deactivated_listings_id', null);
$template_processor->assign('expired_contracts_id', null);
$template_processor->assign('notified_saved_searches_id', $notified_saved_searches_sid);
$scheduler_log = $template_processor->fetch('task_scheduler_log.tpl');
if ($log_file = #fopen('task_scheduler.log', 'a+')) {
fwrite($log_file, $scheduler_log);
fclose($log_file);
}
SJB_DB::query('INSERT INTO `task_scheduler_log`
(`last_executed_date`, `notifieds_sent`, `expired_listings`, `expired_contracts`, `log_text`)
VALUES ( NOW(), ?n, ?n, ?n, ?s)',
count($notified_saved_searches_sid), count($expired_listings_id), count($expired_contracts_id), $scheduler_log);
} catch(Exception $e){
echo $e->getMessage();
}
}
} // END class SJB_Miscellaneous_SendNotifications extends SJB_Function
Is there a good way to utilise ZeroMQ for this type of operation where I want to free loop operations especially when it reaches $saved_searches foreach loop?

How to convert PHP to XML output

I have a php code. this code outputs an HTML. I need to modify this code to output an XML.
ANy ideas as to how shall I go about doing this. Is there any XML library available that directly does the job or do i have to manually create each node.?
My php code is:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
a {text-decoration:none; color:black;}
</style>
</head>
<body>
<?php
$a=$_POST["title"];
$b=$_POST["name"];
$c="http://www.imdb.com/search/title?title=".urlencode($a)."&title_type=".urlencode($b);
$d=file_get_contents($c);
preg_match_all('/<div id="main">\n(No results.)/', $d,$nore);
preg_match_all('#<img src="(.*)"#Us', $d, $img);//image
preg_match_all('/<a\s*href="\/title\/tt[0-9]*\/">((?:[a-z]*(?:&*[.]*)?\s*-*[a-z]*[0-9]*[^<])+)/i',$d,$tit); //title
preg_match_all('/<span\sclass="year_type">\s*\(([\d]*)/',$d,$ye); //movie year working fine
preg_match_all('#<span class="credit">\n Dir: (.*)\n(?: With:)?#Us',$d,$dir); //director
preg_match_all('/<span class="rating-rating"><span class="value">([\w]*.[\w]*)/i',$d,$rat); //rating
preg_match_all('/<a\shref="(\/title\/tt[0-9]*\/)"\s*[title]+/i',$d,$lin); //link
for($i=0;$i<5;$i++)
{
if (#$rat[1][$i]=="-")
$rat[1][$i]="N/A";
}
for($i=0;$i<5;$i++)
{
if(#$dir[1][$i]=="")
$dir[1][$i]="N/A";
}
if(count($tit[1])>5)
$cnt=5;
else
$cnt=count($tit[1]);
echo"<center><b>Search Result</b></center>";
echo "<br/>";
echo "<center><b>\"$a\"of type\"$b\":</b></center>";
echo"<br/>";
if(#$nore[1][0]=="No results.")
echo "<center><b>No movies found!</b></center>";
else
{
echo "<center><table border=1><tr><td><center>Image</center></td><td><center>Title</center></td><td><center>Year</center></td><td><center>Director</center></td><td><center>Rating(10)</center></td><td><center>Link to Movie</center></td></tr>";
for($j=0;$j<$cnt;$j++)
{
echo "<tr>";
echo "<td>".#$img[0][$j+2]."</td>";
echo "<td><center>".#$tit[1][$j]."</center></td>";
echo "<td><center>".#$ye[1][$j]."</center></td>";
echo "<td><center>".#$dir[1][$j]."</center></td>";
echo "<td><center>".#$rat[1][$j]."</center></td>";
echo '<td><center><a style="text-decoration:underline; color:blue;" href="http://www.imdb.com'.#$lin[1][$j].'">Details</a></center></td>';
echo "</tr>";
}
echo "</table></center>";
}
?>
</body>
</html>
Expected XML output:
<result cover="http://ia.mediaimdb.com/images
/M/MV5BMjMyOTM4MDMxNV5BMl5BanBnXkFtZTcwNjIyNzExOA##._V1._SX54_
CR0,0,54,74_.jpg" title="The Amazing Spider-Man(2012)"year="2012"
director="Marc Webb" rating="7.5"
details="http://www.imdb.com/title/tt0948470"/>
<result cover="http://ia.mediaimdb.
com/images/M/MV5BMzk3MTE5MDU5NV5BMl5BanBnXkFtZTYwMjY3NTY3._V1._SX54_CR0,
0,54,74_.jpg" title="Spider-Man(2002)" year="2002"director="Sam Raimi"
rating="7.3" details="http://www.imdb.com/title/tt0145487"/>
<result cover="http://ia.mediaimdb.
com/images/M/MV5BODUwMDc5Mzc5M15BMl5BanBnXkFtZTcwNDgzOTY0MQ##._V1._SX54_
CR0,0,54,74_.jpg" title="Spider-Man 3 (2007)" year="2007" director="Sam
Raimi" rating="6.3" details="http://www.imdb.com/title/tt0413300"/>
<result cover="http://i.mediaimdb.
com/images/SF1f0a42ee1aa08d477a576fbbf7562eed/realm/feature.gif" title="
The Amazing Spider-Man 2 (2014)" year="2014" director="Sam Raimi"
rating="6.3" details="http://www.imdb.com/title/tt1872181"/>
<result cover="http://ia.mediaimdb.
com/images/M/MV5BMjE1ODcyODYxMl5BMl5BanBnXkFtZTcwNjA1NDE3MQ##._V1._SX54_
CR0,0,54,74_.jpg" title="Spider-Man 2 (2004)" year="2004" director="Sam
Raimi" rating="7.5" details="http://www.imdb.com/title/tt0316654"/>
</results>
First thing, you're parsing your html result with regex which is inefficient, unnecessary, and... well, you're answering to the cthulhu call!
Second, parsing IMDB HTML to retrieve results, although valid, might be unnecessary. There are some neat 3rd party APIs that do the job for you, like http://imdbapi.org
If you don't want to use any 3rd party API though, IMHO, you should, instead, parse the HTML using a DOM parser/manipulator, like DOMDocument, for instance, which is safer, better and, at the same time, can solve your HTML to XML problem.
Here's the bit you asked (build XML and HTML from results):
function resultsToHTML($results)
{
$doc = new DOMDocumet();
$table = $doc->createElement('table');
foreach ($results as $r) {
$row = $doc->createElement('tr');
$doc->appendChild($row);
$title = $doc->createElement('td', $r['title']);
$row->appendChild($title);
$year = $doc->createElement('td', $r['year']);
$row->appendChild($year);
$rating = $doc->createElement('td', $r['rating']);
$row->appendChild($rating);
$imgTD = $doc->createElement('td');
//Creating a img tag (use only on)
$img = $doc->createElement('img');
$img->setAttribute('src', $r['img_src']);
$imgTD->appendChild($img);
$row->appendChild($imgTD);
$imgTD = $doc->createElement('td');
//Importing directly from the old document
$fauxDoc = new DOMDocument();
$fauxDoc->loadXML($r['img']);
$img = $fauxDoc->getElementsByTagName('img')->index(0);
$importedImg = $doc->importNode('$img', true);
$imgTD->appendChild($importedImg);
$row->appendChild($imgTD);
}
return $doc;
}
function resultsToXML($results)
{
$doc = new DOMDocumet();
$root = $doc->createElement('results');
foreach ($results as $r) {
$element = $root->createElement('result');
$element->setAttribute('cover', $r['img_src']);
$element->setAttribute('title', $r['title']);
$element->setAttribute('year', $r['year']);
$element->setAttribute('rating', $r['rating']);
$root->appendChild($element);
}
$doc->appendChild($root);
return $doc;
}
to print them you just need to
$xml = resultsToXML($results);
print $xml->saveXML();
Same thing with html
Here's a refactor of your code with DOMDocument, based on your post:
<?php
//Mock IMDB Link
$a = 'The Amazing Spider-Man';
$b = 'title';
$c = "http://www.imdb.com/search/title?title=".urlencode($a)."&title_type=".urlencode($b);
// HTML might be malformed so we want DOMDocument to be quiet
libxml_use_internal_errors(true);
//Initialize DOMDocument parser
$doc = new DOMDocument();
//Load previously downloaded document
$doc->loadHTMLFile($c);
//initialize array to store results
$results = array();
// get table of results and extract a list of rows
$listOfTables = $doc->getElementsByTagName('table');
$rows = getResultRows($listOfTables);
$i = 0;
//loop through all rows to retrieve information
foreach ($rows as $row) {
if ($title = getTitle($row)) {
$results[$i]['title'] = $title;
}
if (!is_null($year = getYear($row)) && $year) {
$results[$i]['year'] = $year;
}
if (!is_null($rating = getRating($row)) && $rating) {
$results[$i]['rating'] = $rating;
}
if ($img = getImage($row)) {
$results[$i]['img'] = $img;
}
if ($src = getImageSrc($row)) {
$results[$i]['img_src'] = $src;
}
++$i;
}
//the first result can be a false positive due to the
// results' table header, so we remove it
if (isset($results[0])) {
array_shift($results);
}
FUNCTIONS
function getResultRows($listOfTables)
{
foreach ($listOfTables as $table) {
if ($table->getAttribute('class') === 'results') {
return $table->getElementsByTagName('tr');
}
}
}
function getImageSrc($row)
{
$img = $row->getElementsByTagName('img')->item(0);
if (!is_null($img)) {
return $img->getAttribute('src');
} else {
return false;
}
}
function getImage($row, $doc)
{
$img = $row->getElementsByTagName('img')->item(0);
if (!is_null($img)) {
return $doc->saveHTML($img);
} else {
return false;
}
}
function getTitle($row)
{
$tdInfo = getTDInfo($row->getElementsByTagName('td'));
if (!is_null($tdInfo) && !is_null($as = $tdInfo->getElementsByTagName('a'))) {
return $as->item(0)->nodeValue;
} else {
return false;
}
}
function getYear($row)
{
$tdInfo = getTDInfo($row->getElementsByTagName('td'));
if (!is_null($tdInfo) && !is_null($spans = $tdInfo->getElementsByTagName('span'))) {
foreach ($spans as $span) {
if ($span->getAttribute('class') === 'year_type') {
return str_replace(')', '', str_replace('(', '', $span->nodeValue));
}
}
}
}
function getRating($row)
{
$tdInfo = getTDInfo($row->getElementsByTagName('td'));
if (!is_null($tdInfo) && !is_null($spans = $tdInfo->getElementsByTagName('span'))) {
foreach ($spans as $span) {
if ($span->getAttribute('class') === 'rating-rating') {
return $span->nodeValue;
}
}
}
}
function getTDInfo($tds)
{
foreach ($tds as $td) {
if ($td->getAttribute('class') == 'title') {
return $td;
}
}
}

Categories