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

IF Statement & Two Tables With Different Echoes
I'm retrieving two tables in a single query using UNION ALL, like so:

Code: $query = "SE

Count Session and Trigger Events
I am New in PHP, seeking a method to count logged users by counting the sessions or any …, is

How to ask a regex question?
Hi, I thought I'd share some of my insight after seeing too many bad questions that either get ignor

Multi Level Array Problem
hi all,

For example I have array like below:

$temp = array(array('north america', 'us'

Wierd if else problem
Hi guys,

this probably aint wierd for you, but it seems like php is playin up to me. may b i

How to read CSS message data
Hi,
I have a requirement here. When working as a Dev angel for multiple customers its really di

Email to a friend script problems
I have this send-to-a-friend script with 2 issues:


1) When you open the form popup on a p

need to add "sizes" to shopping cart
Hey guys, I am trying to figure out a way to add a "size" selector on to this bit of code.

Strange PHP/mySQL error ... am I just tired?
Code: <?

## CONNECT TO DB FUNCTION!
function ConnectTo($db2con)
{
$hostNam

quotes changing
hi all

in my content

opening quotes " changes to “

close qu

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