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
Async WSAConnect failed on XP with error code = 2 ("File not found")
Hi all,
I have very strange bug, please help me if you can.
It is reproduced o
COOIS - Saving Object Overview WIP Status layouts
COOIS - Would like to be able to save the layout of an Object Overview - WIP Status report. There i
Problem with PHP/mySQL login code
Hello,
There is an error in my login script and I can't figure out what it is...
I believe
PHP IMAGE UPLOAD SCRIPT
Hi for the last week i have been looking for scripts that will upload a photo to a certain folder wh
Using cURL to PUT
Can somebody help with the correct php code to make a cURL PUT request. Here is a sample of code bel
pull content
I have an existing page, domain/adverts.php which has a good PR. I've just rebuilt my site and the n
Mail Form receiving emails with no content
Hi, I hope someone here can help me.
I have a simple form in my website, it was working OK, after
Passing Variables
What I'm wanting to do is when the user clicks on Arenas it will know the name of the country it's w
Gridview Not updating in Update Panel
I have a gridview, three dropdown list boxes, and a button on my form. What is displayed in the gri
Count
Getting the same count everytime
Code:
$visitquery = mysql_query("SELECT COUNT(*) FR