Results 1 to 8 of 8

Thread: factor submission script?

  1. #1
    Senior Member Frodo42's Avatar
    Join Date
    Nov 2002
    Location
    Jutland, Denmark
    Posts
    299

    factor submission script?

    I'm wondering if there is a simpler way to submit factors than having to open a browser and then go to www.seventeenorbust.com.

    There must be some way to make a script in Linux that automaticly submits new factors to the text-field on the homepage and then presses the submit button.

    I've been trying to google for at solution, but it's not easy to find the right words to google for. I've also been looking a bit on the man-pages of links and similar programs without much luck.

    So if anyone's got an idea of which program I should use in the script it would be much appreciated.

  2. #2
    Moderator Joe O's Avatar
    Join Date
    Jul 2002
    Location
    West Milford, NJ
    Posts
    643
    I'd recommend doing it in PERL. That way it could easily be ported to Windows.
    Joe O

  3. #3
    Senior Member
    Join Date
    Feb 2003
    Location
    Sweden
    Posts
    158
    Give wget a try -- it's available for lots of platforms. Remember to submit info on the login page as well if you're not always logged in though.

    You'll want to POST factor data to /sieve/sievePost.mhtml. The factor field is called "factors", but look in the file yourself.

    Login info should be POSTed to /login/loginPost.mhtml if you need it, with something like:
    postdata = "-login=true&-username=" + urlencode( cfg_username ) + "&-password=" + urlencode( cfg_password );

  4. #4
    Senior Member Frodo42's Avatar
    Join Date
    Nov 2002
    Location
    Jutland, Denmark
    Posts
    299
    I finally took a little time to read some man-pages

    wget seem to be doing the job, thanks for the tip mKlasson
    the following command is basicly what does it:
    Code:
    wget  --load-cookies cookies.txt --post-file=fact.txt http://www.seventeenorbust.com/sieve/sievePost.mhtm
    The cookies.txt file is taken from the cookie created by the web-site when you log in.
    wget creates a sievePost.mhtml(.* if one already exist) file in which one can see the results of the sumbission (this avoided by the --delete-after tag)
    For this to work I add factors= to the start of my fact.txt file and remove the '+1' at the end of each line of fact.txt.
    For some reason wget won't submit the '+', i guess it's something with the format of strings in UNIX, but I haven't figured out what it is yet.
    Any help on this little problem would be appreciated, I guess one could just make a little workaround script that removed the '+1' part of each line, but I there must be another way ...

    Anways my plan is to cron this job when I leave my computer for longer periods so that I don't need to worry about factors not being submitted in timely fashion.
    I guess I should also should write a little script to sort out which factors have been submitted, but as long as it's only for factoring and one just remember to remove older factors from fact.txt I guess the server load won't be all to big when I only let cron do the job every 24 hours.

  5. #5
    Senior Member
    Join Date
    Feb 2003
    Location
    Sweden
    Posts
    158
    The problem is that + is used to encode a blankspace. %XY can be used to encode any ASCII character by giving the hexadecimal code -- %2B corresponds to a normal plus sign.

  6. #6
    Senior Member Frodo42's Avatar
    Join Date
    Nov 2002
    Location
    Jutland, Denmark
    Posts
    299
    well now I made my workaround using sed
    Code:
    sed {s/+/%2B/} fact.txt > submit.txt
    wget  --load-cookies cookies.txt --post-file=submit.txt http://www.seventeenorbust.com/sieve/sievePost.mhtml
    rm submit.txt
    It probably could be done in a nicer way, but it does the job.
    Thanks for the help mklasson

  7. #7
    Hater of webboards
    Join Date
    Feb 2003
    Location
    København, Denmark
    Posts
    205
    Based on this discussion I've now made the following shell-script which submits any new factors:

    Code:
    #! /bin/sh
    
    rm submit.txt
    /usr/sbin/logtail fact.txt > new_factors.txt
    if [ -s new_factors.txt ]; then
        (echo 'factors='; cat new_factors.txt) | sed -e 's/\+/%2B/' > submit.txt;
        wget --load-cookies ~/17_or_bust/p-1/cookies.txt --post-file submit.txt http://www.seventeenorbust.com/sieve/sievePost.mhtml
    fi
    rm new_factors.txt
    It uses a little (often overlooked) utility called logtail to get the new factors, and then it's basically what Frodo42 did, except that I've created a custom cookies.txt that only contains the cookie from www.seventeenorbust.com.

  8. #8
    Senior Member Frodo42's Avatar
    Join Date
    Nov 2002
    Location
    Jutland, Denmark
    Posts
    299
    This is working out just fine, thanks hc_grove.
    btw. logtail is in gentoo contained in the e-build logsentry or can be found on http://www.fourmilab.ch/webtools/logtail/

Posting Permissions

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