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
34
Other forums
php mail form text wont appear / javascript included
Guys/gals...
I am running into a problem whereby I have a great piece of javascript code that
Spaghetti Code
So.
I've pretty much reached the point where I have so many isset s on one page that I can't
Last character removed
I have created a string from an array. I have inserted commas from my form values. I am trying to re
random generation
hi
i need help with generating this
numbers from 1-12
i want to generate in ran
losing variables between php brackets
Hi
have got this code:
Code: $id=mysql_result($result,0,"itemid");
$title=mys
Word Trimming
Hi Guys & Gals!!
Hope you are all ok....
I need some help with the following
PHP webpage & array print issue
I have this code running, and it works perfectly … however, see my bottom bit about what I see
Is it possible to view php source code??
Hi All
I was just wondering if it's possible to view a websites php source code?
I know
Parse Error
Hi Guys,
I have a function in my class which returns a string link variable. The problem is i
Preserving user-entered linebreaks
Hi, I'm building a web 2.0 thingy from scratch and I wanna display text which users input. It's all