Help with file_get_html


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

The following code gives the expected results:

<html>
<head>
Did you know?Explore Trending and Topic pages for more stories like this.
<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

Array disappearing in foreach loop
Okay, I have this problem where an array will become undefined in a foreach loop.

Here is the

Querying info from one table based on info in another
Hi, I am currently trying to make a part for my user driven website where one user can subscribe to

Matchcode in ALV change header column
Hello everyone,

I am working in an SAP system that is currently in upgrade and conversion

uploading video files into mysql in php
hi,
I have the video files which i have to upload into mysql db. along with creating thumbnails f

onClick='location.href=index.htm'> not working
Below is my code:

echo "<input type='button' value='redirect' onClick='location.h

Wrong Info sent Using $get in form
Hi i have this code that i tried to make to send some info from one page to aother with lots of ppls

help removing unwanted graphic
How do I remove the small elongated rectangular shape between the "Latest post" and "

Printing issues with xMII 11.5
For some reason, we have one report (and only one) that is giving us fits when trying to print. The

calculator
I can't figure out why this code doesn't work. No error messages. Page loads.

Code: <

Linked Keywords
I am trying to get a script that makes my predefined keyword converted to links and / or converted t

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