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
Email Form Syantax Issue 2
How to make this look FROM:"OUR TEAM" instead of FROM:abc@mail.com
$headers = "
Delete all files in folder except with certain name
I have a script that I want to delete all files in a folder (taken from a database) except for one n
SESSION question
I am building an application , a directory for auctions.
For SEO i made a script which copies a p
Cloud Computing?
Hello,
I was wondering if anyone could help explain this term to me. I'm starting to hear it
subtract 1 from value entered in text field
Hi
How do I subtract 1 from the vaue entered into a text field?
Thanks
DateObject and Nulls
Hi all,
I have an array mapped to a value object. One of the items in the array is a PHP Date
Transport data between itab and textfield on ALV event
Hallo,
I have a ALV Grid ( cl_gui_alv_grid ) and I also have hotspot click event with a h
help with Get_
ok some how this is not working i am not sure what i am doing wrong here but what this does is when
MySQL-PHP Query Results Help
Hello all. I'm hoping to be able to get some help in solving a problem with query/rowcount output. I
PHP Multiples of 2, Show posts...not working (wordpress)
I have been using this code to show div.example with 6 li columns inside it, each li is a post with