Thread: os.system()

    #1
  1. Only the strong survives!!.
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Feb 2003
    Location
    A World of wonders.
    Posts
    5,583
    Rep Power
    407

    os.system()


    Ok im tring to code this dictionary search program.. but its not fully working for me from what i see if the url has an = sign then it wont work it will just open a regular explorer window.. now it i was to remove it.. then my progrom works and it will be transferring to the url does anyone knows why??? this only happends on windows.. tested it on linux and works like a charm.. here is the part of my code that its messing up on windows..

    Code:
    search = self.entry.get()
    		os.system("explorer http://www.google.com/search?sourceid=navclient&q="+search)
    
    :confused:
    any idea.. the only problem is the equal sign
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Mmm this isnt how i'd choose to get the contents of a webpage X, you should look at the urllib module i.e.

    Code:
    import urllib
    
    param = urllib.urlencode({'sourceid': 'navclient', 'q': seach})
    page = urllib.urlopen('http://www.google.com/seach', params)
    
    print page.read(), page.info() #more data available
    Its a little longer i'll give you but it is very cross platform and of course Pythonic.. this wont work with google since they've blocked automated systems

    But use PyGoogle, its easy to use! it gives you allot more controle than your gonna get using urllib and regex!

    http://diveintomark.org/projects/pygoogle/

    Mark.
    programming language development: www.netytan.com Hula

  4. #3
  5. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,624
    Rep Power
    4247
    This is a bad idea from a security standpoint too
    Code:
    search = self.entry.get()
    os.system("explorer http://www.google.com/search?sourceid=navclient&q="+search)
    At the very minimum, you should urlencode search, otherwise people can input something like:
    bogus; rm -rf /
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  6. #4
  7. Only the strong survives!!.
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Feb 2003
    Location
    A World of wonders.
    Posts
    5,583
    Rep Power
    407
    Originally posted by Scorpions4ever
    This is a bad idea from a security standpoint too
    Code:
    search = self.entry.get()
    os.system("explorer http://www.google.com/search?sourceid=navclient&q="+search)
    At the very minimum, you should urlencode search, otherwise people can input something like:
    bogus; rm -rf /
    hehe i wont even dare to code something like this on linux :P this code is being ran on winblows


    btw.. sorry i didnt mean to post the google page see i was creating a dictionary search program just added google for testing to see if it wold work or not.. and for got to replace it with the correct url
    Last edited by xlordt; November 21st, 2003 at 03:14 PM.

IMN logo majestic logo threadwatch logo seochat tools logo