tgallagher26
03-23-2009, 06:06 PM
Ok so here it goes I am trying to save the top 100 search terms to a txt file
Here is the code I am tying to use.
<?php
$feed = simplexml_load_file('http://www.google.com/trends/hottrends/atom/hourly');
$children = $feed->children('http://www.w3.org/2005/Atom');
$parts = $children->entry;
foreach ($parts as $entry) {
$details = $entry->children('http://www.w3.org/2005/Atom');
$dom = new domDocument();
@$dom->loadHTML($details->content);
$anchors = $dom->getElementsByTagName('a');
foreach ($anchors as $anchor) {
$url = $anchor->getAttribute('href');
$urltext = $anchor->nodeValue;
}
}
$file = 'top100.txt';
$current = file_get_contents($file);
$current .= $urltext;
file_put_contents($file, $current);
?>
The problem I am having is that its only saving the 100th term also it doesnt save it on a new line.
The are the pages
List I am trying to save (Its upated Hourly) (http://www.google.com/trends/hottrends/atom/hourly)
Print page (Code above is here) (http://kywordpro.com/top100print.php)
Text file (Trying to Save here) (http://kywordpro.com/top100.txt)
Any help would be appreciated.
TIm..
Here is the code I am tying to use.
<?php
$feed = simplexml_load_file('http://www.google.com/trends/hottrends/atom/hourly');
$children = $feed->children('http://www.w3.org/2005/Atom');
$parts = $children->entry;
foreach ($parts as $entry) {
$details = $entry->children('http://www.w3.org/2005/Atom');
$dom = new domDocument();
@$dom->loadHTML($details->content);
$anchors = $dom->getElementsByTagName('a');
foreach ($anchors as $anchor) {
$url = $anchor->getAttribute('href');
$urltext = $anchor->nodeValue;
}
}
$file = 'top100.txt';
$current = file_get_contents($file);
$current .= $urltext;
file_put_contents($file, $current);
?>
The problem I am having is that its only saving the 100th term also it doesnt save it on a new line.
The are the pages
List I am trying to save (Its upated Hourly) (http://www.google.com/trends/hottrends/atom/hourly)
Print page (Code above is here) (http://kywordpro.com/top100print.php)
Text file (Trying to Save here) (http://kywordpro.com/top100.txt)
Any help would be appreciated.
TIm..