Say you do a search on something that produces a web page listing things such as a top 100 list of hit singles.
You can select the content of the page by dragging your mouse over the area, and then CTRL->C CTRL-V to a spread sheet. I use Open Office (calc).
Then, if you are lucky, the spreadsheet will automatically separate the data into convenient columns.
Then delete the columns of content you don't want and save the spreadsheet as CSV format but as say data.txt
Then in PHP, you can write a simple script to read the text file and parse the data to SQL or PHP array code such as:
PHP Code:
<pre>
<?php
$menData = file_get_contents('men.txt');
$womenData = file_get_contents('female.txt');
$surnameData = file_get_contents('surnames.txt');
$m = explode("\r\n", $menData);
$f= explode("\r\n", $womenData);
$s = explode("\r\n", $surnameData);
$a = "\$m = array (\n";
foreach($m as $n) $a .= "\t'" . ucfirst(strtolower(trim($n, '"'))) . "',\n";
$a .= ");\n";
$a .= "\n\$f = array (\n";
foreach($f as $n) $a .= "\t'" . ucfirst(strtolower(trim($n, '"'))) . "',\n";
$a .= ");\n";
$a .= "\n\$s = array (\n";
foreach($s as $n) $a .= "\t'" . ucfirst(strtolower(trim($n, '"'))) . "',\n";
$a .= ");\n";
file_put_contents('names.tmp', $a);
?>
OK
This is just an example of code I used to produce a list of people's names on the windows platform (hence the carriage return, line break nonsense). The output file: names.tmp contained some PHP code that I cut and pasted into the actual script that I was writing.
So this is a way to save you a huge amount of manual effort when compiling data from the web to use in a database or web app.
For fun, you can try the random name generator that I came up with here: Name Generator Press F5 on your keyboard to generate a new name.
Bookmarks