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

4
  • 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 us2.php.net/preg_match regexp. Commented Nov 26, 2013 at 7:59
  • i want to get about GE paragraph and some more companies like that Commented Nov 26, 2013 at 8:06
  • linkedin.com/company/… Commented Nov 26, 2013 at 8: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) Commented Nov 26, 2013 at 8:12

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

5 Comments

@ Enissay : can you please tell me that how could i get the logo name and also logo from the same address thanks
:) 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??
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 :)
ok thanks again. BUt currently I'm facing this problem that failed to open stream functon file_put_contents() :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.