Help with file_get_html


Posted on 16th Feb 2014 07:03 pm by admin

The following code gives the expected results:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Generate Description and Tags</title>
</head>
<body>
<?php
include 'simple_html_dom.php';
$entityURL = "http://google.com";
echo "Entity URL: ", $entityURL,"
";
$html = file_get_html($entityURL);
$tot_html_str = $html->save();
$tot_html_strlen = strlen($tot_html_str);
echo "Strlen of total HTML: ",$tot_html_strlen,"
";
?>
</body>
</html>

results in:

Entity URL: http://google.com
Strlen of total HTML: 7403

However, if I read the URL from a file, I am not able to scrape the HTML:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Generate Description and Tags</title>
</head>
<body>
<?php
include 'simple_html_dom.php';
$myFile = "/home/prakash/foo.txt";
$src_handle = fopen($myFile, "r");
$entityURL = fgets($src_handle, 4096);
echo "Entity URL: ", $entityURL,"
";
$html = file_get_html($entityURL);
$tot_html_str = $html->save();
$tot_html_strlen = strlen($tot_html_str);
echo "Strlen of total HTML: ",$tot_html_strlen,"
";
?>
</body>
</html>

results in:

Entity URL: http://google.com
Strlen of total HTML: 0

What do I need to do differently to read the URL from a file.

No comments posted yet

Your Answer:

Login to answer
206 Like 34 Dislike
Previous forums Next forums
Other forums

Insert data in Mysql and move to another page
I'm stuck with this simple problem. I need to insert data in Mysql and then hit submit and move to a

Secure pages Sessions vs. Cookies & session_destroy() help
Im new here and new to PHP, I hope you can help me with some questions.

Im writing my web ap

Google Map
I have done Google Map Integration for one my project. But for that we need the "latitude and l

Ten Operator Syntax
Hi Guys,

I can't figure out why i am getting a parse error with this basic ten op code:

Coding question?
Hey guys, I have a quick question. If I want to make a way for people to pay for health in my game,

how do i make new line after *
First check this page here. and you see my report. Im pulling form a mysql db. I want to beable to m

Best PHP Documentation generator
Hello guys!

I would like to hear from you what is the best PHP documentation generator. Perso

Blocking video streaming
Hello everyone,

I post a message here because i didn't find any solution yet.
I just finis

ok i need to join all this pages to make 1 neat code
i have 5 pages that make up my tv guide it works 100% but i want to make it 1 page if i can or 2, i

need help with mail()
hi i want to send an email with attaching pdf file using php. i have the following script but the pr

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash