Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
[PY] Web Browser?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Sway" data-source="post: 223977" data-attributes="member: 1889"><p><strong>UPDATE:</strong></p><p>** Added exception handlers.</p><p> </p><p><strong>Source:</strong></p><p><a href="http://pastebin.com/Wex9KcA1" target="_blank">http://pastebin.com/Wex9KcA1</a></p><p> </p><p><strong>Snippet:</strong></p><p>[CODE]def main():</p><p> print()</p><p> print("Do not add 'http://'")</p><p> website = input("Website: ")</p><p> print()</p><p> browsers = input("View the list of browsers? ")</p><p> if any(browsers.lower() in choice_yes for choices_yes in browsers.lower()):</p><p> print()</p><p> print('''You can use: 'windows-default' to load the default (favorite) browser.</p><p>You can use any other name aslong as that browser is in your PATH.''')</p><p> print()</p><p> </p><p> browserChoice = input("Browser (use 'windows-default' for the default browser): ")</p><p> </p><p> choice = input("Do you wish to open it in a new tab [NT] or seperate window [W]? ")</p><p> </p><p> if choice.lower() == 'w':</p><p> print()</p><p> print("Opening website in new window...")</p><p> time.sleep(2)</p><p> </p><p> try:</p><p> browser = webbrowser.get(browserChoice)</p><p> webbrowser.open_new("http://%s" % website) </p><p> except webbrowser.Error:</p><p> print()</p><p> print("Invalid browser!")</p><p> startOver()</p><p> else:</p><p> startOver()</p><p> </p><p> elif choice.lower() == 'nt':</p><p> print()</p><p> print("Opening website in new tab...")</p><p> time.sleep(2)</p><p> </p><p> try:</p><p> browser = webbrowser.get(browserChoice)</p><p> webbrowser.open_new_tab("http://%s" % website) </p><p> except webbrowser.Error:</p><p> print()</p><p> print("Invalid browser!")</p><p> startOver()</p><p> else:</p><p> startOver()</p><p> </p><p> else:</p><p> print("I didn't get that..")</p><p> startOver()</p><p>[/CODE]</p><p> </p><p>This is the final update and release of this script. To run it, you must have <strong>Python </strong>installed. </p></blockquote><p></p>
[QUOTE="Sway, post: 223977, member: 1889"] [B]UPDATE:[/B] ** Added exception handlers. [B]Source:[/B] [URL]http://pastebin.com/Wex9KcA1[/URL] [B]Snippet:[/B] [CODE]def main(): print() print("Do not add 'http://'") website = input("Website: ") print() browsers = input("View the list of browsers? ") if any(browsers.lower() in choice_yes for choices_yes in browsers.lower()): print() print('''You can use: 'windows-default' to load the default (favorite) browser. You can use any other name aslong as that browser is in your PATH.''') print() browserChoice = input("Browser (use 'windows-default' for the default browser): ") choice = input("Do you wish to open it in a new tab [NT] or seperate window [W]? ") if choice.lower() == 'w': print() print("Opening website in new window...") time.sleep(2) try: browser = webbrowser.get(browserChoice) webbrowser.open_new("http://%s" % website) except webbrowser.Error: print() print("Invalid browser!") startOver() else: startOver() elif choice.lower() == 'nt': print() print("Opening website in new tab...") time.sleep(2) try: browser = webbrowser.get(browserChoice) webbrowser.open_new_tab("http://%s" % website) except webbrowser.Error: print() print("Invalid browser!") startOver() else: startOver() else: print("I didn't get that..") startOver() [/CODE] This is the final update and release of this script. To run it, you must have [B]Python [/B]installed. [B][/B] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
[PY] Web Browser?
Top