Creating variable URLs & Other Expressions

Discussion in 'Mac Basics and Help' started by MacAttack85, Jul 30, 2009.

  1. MacAttack85 macrumors newbie

    MacAttack85

    Joined:
    Mar 11, 2009
    Location:
    Gold Coast
    #1
  2. Makosuke macrumors 603

    Joined:
    Aug 15, 2001
    Location:
    The Cool Part of CA, USA
    #2
    It would be very simple to make Excel do this, and if you don't own that I expect OpenOffice's spreadsheet could also be pressed into duty.

    Alternately, if you're even vaguely familiar with any scripting language, it would take almost nothing to print a string, increment a variable by one, and repeat a few hundred thousand times. Of course, if you're not familiar with a scripting language, learning enough of one to do this would probably have been much faster than searching for a tool for days.
     
  3. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #3
    Here's a small Perl script. Just copy and paste it into a file, save it with whatever name. Then from Terminal it will output those URLs. It's currently set to 20, but you can increase that to 300,000.
    PHP:
    #!/usr/bin/perl
    my $i 1;
    while (
    $i++ <= 20) {
      print 
    "http://www.abc.com/pass.php?user=$i&d=1\n";
    }
    Run from Terminal,
    Code:
    perl ~/Desktop/nameOfFile.pl
    If you want to save the output to a file,
    Code:
    perl ~/Desktop/nameOfFile.pl > ~/Desktop/output.txt
     
  4. MacAttack85 thread starter macrumors newbie

    MacAttack85

    Joined:
    Mar 11, 2009
    Location:
    Gold Coast
    #4
    Thank you so much for your help. You seem to know what you are talking about. However, I can't seem to get it to work.

    I copied your Perl Script, saved it as plain text and with the extension .php

    Code:
    #!/usr/bin/perl 
    my $i = 1; 
    while ($i++ <= 20) { 
      print "http://www.abc.com/pass.php?user=$i&d=1\n"; 
    } 

    Opened terminal
    Code:
    perl ~/Desktop/nameOfFile.pl
    Created the output file
    Code:
    perl ~/Desktop/nameOfFile.pl > ~/Desktop/output.txt
    With the ~, do I put my user name? and is the pl the perl extension.

    Thank you for your help :)
     
  5. MacAttack85 thread starter macrumors newbie

    MacAttack85

    Joined:
    Mar 11, 2009
    Location:
    Gold Coast
  6. samliew macrumors newbie

    Joined:
    Aug 2, 2009
    #6
    Wow, glad to find my scripts are helpful! I made this script previously to help me generate links to download movie files from funnyplace.org, as their filenames were sequential, but they have since changed. Now I have a greasemonkey (Firefox plugin) script to grab the download link instead. See: http://userscripts.org/scripts/show/54829

    For other generators and games that I made, visit my programming page at http://www.samliew.com/programming.php
    If you have a problem that could possibly be solved by scripting, do let me know as I love a challenge! (contact me via my site)

    All the best!
     
  7. MacAttack85 thread starter macrumors newbie

    MacAttack85

    Joined:
    Mar 11, 2009
    Location:
    Gold Coast
    #7
    Glad I found it. Worked perfectly

    Is there anyway you can open 300,000 urls at once without opening them in tabs and crashing my browser :D

    That would be a challenge. I can open and create about 350 in tabs before Safari crashes
     
  8. samliew macrumors newbie

    Joined:
    Aug 2, 2009
    #8
    Possible to create a PHP version where you get to download a text file with the URLs instead, but I never tried before.
     

Share This Page