1

I want to get content from another website. I have tried this below coding.

<?php
    require_once("simple_html_dom.php");

    $webpage = file_get_html('https://stackoverflow.com/questions/9813273/web-scraping-in-php');
    $gettxt = $webpage->find("div#answer-9813422",0)->innertext;
    echo $gettxt;

?>

It prints the HTML results correctly without css styles. But, I have to show the css styles also. How do I get the appropriate css selectors of these HTML section?

enter image description here

Karuppiah RK
  • 3,894
  • 9
  • 40
  • 80
  • You are scraping html and getting html. You won't get the CSS styles this way. One option is to include all CSS files from stackoverflow in your page but that would mess up your page CSS also – Tarun Lalwani Oct 04 '17 at 12:26
  • Do you mean the html? Just leave off `->innertext` – pguardiario Oct 04 '17 at 22:35

0 Answers0