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
Opening Multiple Files/Links in Order.
I want to open links in order/one-by-one and check each for a specific string.
Example:
I
PHP / MySQL Associative Multidimensional Array:
Hello.
I have data in a MySQL Table that adheres to the below: (note, no index, could add if
How to ... (FAQs)
... get e-mail notifications
As several people asked how to get e-mail notifications when new posti
Reg Ex
Im trying to search for the string: srv_9 (Dead ???)
I thought to use preg_match, however I d
extract data
Code: <div class="post hentry uncustomized-post-template">
Warning: mysql_num_rows() expects parameter 1
When i add quote at the end of this link
example:http://localhost/articlemania/category.php?cid=3
Form a inline view based on the results of the previous query?
Hi Experts,
Can we form a inline view on the results of a previous query (another inline view)?
calendar dates and hours compare problem
i have a calendar in wordpress, everything works great except that i can make 2 meetings at the same
MySQL noob question
hi guys
I have a simple mysql table set up, along the lines of
Col 1 - Col 2 - Date_l
Basic Question Regarding PHP Includes
Hi
Just starting out with PHP.
Working on a site that uses some basic includes, these