Results 1 to 1 of 1

Thread: How To Import Lists Of Cut And Paste Webpage Data To PHP

  1. #1

    How To Import Lists Of Cut And Paste Webpage Data To PHP

    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:
    $womenData file_get_contents('female.txt');
    $surnameData file_get_contents('surnames.txt');

    $m explode("\r\n"$menData);
    $s explode("\r\n"$surnameData);

    $a "\$m = array (\n";
    $m as $n$a .= "\t'" ucfirst(strtolower(trim($n'"'))) . "',\n";
    $a .= ");\n";

    $a .= "\n\$f = array (\n";
    $f as $n$a .= "\t'" ucfirst(strtolower(trim($n'"'))) . "',\n";
    $a .= ");\n";

    $a .= "\n\$s = array (\n";
    $s as $n$a .= "\t'" ucfirst(strtolower(trim($n'"'))) . "',\n";
    $a .= ");\n";

    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.
    Last edited by Andy101; 29 January, 2011 at 15:46 PM. Reason: Added a link to my random name generator script

Similar Threads

  1. Problem to Import E-mail
    By blasir in forum PHPAutoresponder Support
    Replies: 1
    Last Post: 25 March, 2011, 17:27 PM
  2. How to import database to Wordpress?
    By thesyndicate in forum Wordpress
    Replies: 6
    Last Post: 12 April, 2010, 22:15 PM
  3. where i should paste this code?
    By garfish in forum Programming
    Replies: 4
    Last Post: 9 April, 2010, 07:39 AM
  4. [WTS] Paste-It script just for 15$
    By chetan in forum Scripts
    Replies: 6
    Last Post: 26 September, 2009, 15:34 PM
  5. [Free] Low rate copy paste forum posting services
    By badmash in forum Services
    Replies: 0
    Last Post: 12 September, 2009, 07:25 AM

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts