2

This may be possibly duplicate. but I want to know that how can I get text from a paragraph using simple HTML DOM Parser or something else which have a more button (perhaps prefferably called a link) at the end of paragraph. e.g This is test string and I want to get this data but don't know how to [more...]

and the actual text is This is test string and I want to get this data but don't know how to get it Please anybody help me.

So anyone who could explain how can I get this complete paragraph. Thanks in advance

Mubin
  • 4,325
  • 5
  • 33
  • 55
  • Do you need to check some text that you know you want to search or do you generally need to search for a text that you don't know? In any case, I'm pretty sure you need to use http://us2.php.net/preg_match regexp. – briosheje Nov 26 '13 at 07:59
  • i want to get about GE paragraph and some more companies like that – Mubin Nov 26 '13 at 08:06
  • http://www.linkedin.com/company/1015?trk=vsrp_companies_res_name&trkInfo=VSRPsearchId%3A2646459271384809644652%2CVSRPtargetId%3A1015%2CVSRPcmpt%3Aprimary# – Mubin Nov 26 '13 at 08:07
  • @ mcuadros . I'm currently getting other fileds using PHP, so I don't know it is a js Q or not(PHP doing this smoothly to get other sections) – Mubin Nov 26 '13 at 08:12

1 Answers1

2

All the source code of this web page is reformatted and rearranged using JavaScript, and since Simple HTML DOM doesnt handle JS, you must work on the raw code (before JS alterations) wich you can check using ctrl+U... Then, based on it, you write your parser correctly...

He're a working code answering your question:

// includes Simple HTML DOM Parser
include "simple_html_dom.php";

$url = 'http://www.linkedin.com/company/1015?trk=vsrp_companies_res_name&trkInfo=VSRPsearchId%3A2646459271384809644652%2CVSRPtargetId%3A1015%2CVSRPcmpt%3Aprimary#';

//Create a DOM object
$html = new simple_html_dom();
// Load HTML from a string
$html->load_file($url);

// Get the node having "text-logo" class
$div = $html->find('div.text-logo', 0);

echo $div;
echo "<hr>";

// Get logo node
$logo = $html->find('img.logo', 0);

echo $logo->alt ." => ". $logo->src;

// Clear dom object
$html->clear(); 
unset($html);

Working DEMO

Enissay
  • 4,969
  • 3
  • 29
  • 56
  • @ Enissay : can you please tell me that how could i get the logo name and also logo from the same address thanks – Mubin Nov 26 '13 at 22:34
  • :) thanks man..this will give me logo src but can you provide me an example that how could I grab image and store it on local machine?? – Mubin Nov 26 '13 at 22:50
  • It would be easy since you have the image's url... You'll find a plenty of answers here and on google... If you fails, feel free to start a new question so we don't overload this one :) – Enissay Nov 26 '13 at 22:58
  • ok thanks again. BUt currently I'm facing this problem that failed to open stream functon file_put_contents() :( – Mubin Nov 26 '13 at 23:01
  • Did you check this: http://stackoverflow.com/questions/9801471/download-image-from-url-using-php-code – Enissay Nov 26 '13 at 23:11