I have this script named test.php:
<?php
// Get a file into an array. In this example we'll go through HTTP to get
// the HTML source of a URL.
$lines =
file('http://www.google.fr/search?q=beautiful&hl=fr&lr=&ie=UTF-8&oe=UTF-8&start=10&sa=N');
// Loop through our array, show html source as html source; and line numbers too.
foreach ($lines as $line_num => $line) {
echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br>\n";
}
?>
This script dosen't work. I receive the following warning:
Warning:
file("http://www.google.fr/search?q=beautiful&hl=fr&lr=&ie=UTF-8&oe=UTF-8&start=10&sa=N")
- No such file or directory in test.php on line 4
With this script I want to get the HTML source of a search result on google. I tried
with another search engines and it works, only with google dosen't work.
For examle I have the script:
<?php
// Get a file into an array. In this example we'll go through HTTP to get
// the HTML source of a URL.
$lines = file('http://search.yahoo.com/search?p=sexe&ei=UTF-8&b=1');
// Loop through our array, show html source as html source; and line numbers too.
foreach ($lines as $line_num => $line) {
echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br>\n";
}
?>
and I have no problem with it.
Can you help me? Maybe you have a suggestion what shall I do to make it work?
This is pretty stragne because I tested the code at home and it works. I also tested
it at one of my friends and it dosen't work, at my work also it dosen't work.
Thanks for your support!
Adina
P.S. I tried to change the user agent header and it dosen't work.