# Python Tips - Webbrowser package  Python is often used as an automation tool. Today, we take a look at the `webbrowser` package. *Python est souvent utilisé comme outil d'automatisation. Aujourd'hui, nous nous penchons sur le paquet `webbrowser`.* This module is quite simple to use. That makes it very cool to work with to setup an automation script rapidly. *Ce module est très simple à utiliser. Il est donc très agréable de travailler avec lui pour mettre en place rapidement un script d'automatisation.* --- You can import it with: ```Python import webbrowser ``` Simply open an url: ```Python # pass the url as a string webbrowser.open(url) ``` Open a url in a new tab: ```Python # pass the url as a string webbrowser.open_new_tab(url) ``` Open a url in a new window: ```Python # pass the url as a string webbrowser.open_new(url) ``` By using the package this way, you will open the URLs in your default browser. If you wish to use another browser, you will have to use the `controller` object. The list of browsers supported natively can be found [here](https://docs.python.org/3.8/library/webbrowser.html#webbrowser.register). If it's not there, you can use the `webbrowser.register()` function to register it before using the associated controller. --- To get the controller, it's quite simple ```Python # pass the url as a string firefox = webbrowser.get(using="firefox") ``` Then you can use it just like before. ```Python # pass the url as a string firefox.open(url) # pass the url as a string firefox.open_new_tab(url) # pass the url as a string firefox.open_new(url) ```  You made it to the end, bravo! If you have any questions, don't forget to ask. See you next time!  --- You will be able to find a good part of the articles in this account [in this repository](https://github.com/slashformotion/hive-base). To go directly to the section you are currently viewing [click here](https://github.com/slashformotion/hive-base/tree/master/content/series/PythonTips/PythonTips_n5-WebbrowserPackage). [Latest article in the series: ***Python Tips 4 - Playing with recursion*** ](https://peakd.com/hive-163521/@slashformotion/python-tips-4-playing-with-recursion)
author | slashformotion |
---|---|
permlink | python-tips-5-webbrowser-package |
category | hive-163521 |
json_metadata | {"app":"peakd/2020.07.1","format":"markdown","tags":["python","fr","dev","webbrowser"],"users":["slashformotion"],"links":["https://docs.python.org/3.8/library/webbrowser.html#webbrowser.register","https://github.com/slashformotion/hive-base","https://github.com/slashformotion/hive-base/tree/master/content/series/PythonTips/PythonTips_n5-WebbrowserPackage","/hive-163521/@slashformotion/python-tips-4-playing-with-recursion"],"image":["https://www.oneclicksolutions.com.au/wp-content/uploads/2011/07/browsericons-539x205.png","https://images.hive.blog/DQmSkA2zZKCkkqxJKiG1srWbDzi4V74KMnRmg7LfbQDka6z/dividers-06.png"]} |
created | 2020-07-07 12:50:03 |
last_update | 2020-07-07 14:26:51 |
depth | 0 |
children | 4 |
last_payout | 2020-07-14 12:50:03 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.522 HBD |
curator_payout_value | 0.516 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 2,538 |
author_reputation | 2,410,764,686,560 |
root_title | "Python Tips 5 - Webbrowser package" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 98,389,351 |
net_rshares | 3,508,964,909,561 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
arcange | 0 | 63,539,094,337 | 2% | ||
raphaelle | 0 | 1,685,272,943 | 2% | ||
soushi888 | 0 | 1,567,342,332 | 100% | ||
lugaxker | 0 | 682,923,987 | 14.85% | ||
fancybrothers | 0 | 2,702,202,466 | 5% | ||
wargof | 0 | 1,375,946,515 | 65% | ||
bambukah | 0 | 1,139,889,438 | 20% | ||
tykee | 0 | 2,926,621,220 | 50% | ||
francosteemvotes | 0 | 6,707,476,348 | 20% | ||
evildido | 0 | 1,138,634,873 | 10% | ||
aidefr | 0 | 3,796,851,649 | 15% | ||
robotics101 | 0 | 5,338,682,361 | 20% | ||
lpv | 0 | 1,264,366,657 | 3.75% | ||
iptrucs | 0 | 65,979,243,476 | 40% | ||
kamchore | 0 | 155,228,510,318 | 100% | ||
as31 | 0 | 7,105,283,392 | 35% | ||
duke77 | 0 | 3,753,571,872 | 25% | ||
slashformotion | 0 | 611,277,295 | 40% | ||
mmmmkkkk311 | 0 | 153,047,290,749 | 2% | ||
bala41288 | 0 | 40,027,376,825 | 20% | ||
dragibusss | 0 | 1,441,259,969 | 50% | ||
voltagrou | 0 | 1,334,579,828 | 10% | ||
gribouille | 0 | 621,150,388 | 15% | ||
orlandumike | 0 | 7,443,290,797 | 25% | ||
theophile.roos | 0 | 1,380,700,323 | 100% | ||
antisocialist | 0 | 163,328,100,498 | 53% | ||
onepercentbetter | 0 | 2,598,924,791 | 1.25% | ||
imcore | 0 | 1,017,835,672 | 10% | ||
enforcer48 | 0 | 111,261,515,238 | 15% | ||
merlion | 0 | 500,257,332 | 1.25% | ||
steemprotect | 0 | 4,809,069 | 3% | ||
revueh | 0 | 693,335,055 | 20% | ||
zuerich | 0 | 572,579,570,385 | 15% | ||
anttn | 0 | 61,594,649,216 | 30% | ||
cleanplanet | 0 | 752,336,070,048 | 80% | ||
clement.poiret | 0 | 535,466,124 | 100% | ||
otp-one | 0 | 2,925,182,617 | 35% | ||
pboulet | 0 | 7,886,397,967 | 20% | ||
laissez-faire | 0 | 12,921,619 | 100% | ||
ctime | 0 | 339,652,819,615 | 2.5% | ||
hungrybear | 0 | 54,475,342 | 1.25% | ||
oniemaniego | 0 | 7,269,590,064 | 100% | ||
davidlionfish | 0 | 12,870,876,311 | 25% | ||
fengchao | 0 | 2,197,257,311 | 2% | ||
laruche | 0 | 861,359,940,447 | 20% | ||
gitplait | 0 | 74,853,724,220 | 100% | ||
radio-quebec | 0 | 765,456,747 | 50% | ||
louis00334 | 0 | 126,602,908 | 39% | ||
comprendre.hive | 0 | 700,290,607 | 20% |
Thanks to @theophile.roos for burning [800 PLANET](https://hive-engine.com/?p=market&t=PLANET)! You have been rewarded with a 80% vote. Your action makes this project grow and helps to restore a Clean Planet! Join us on our [Discord Channel](https://discord.gg/FkVTpwU) and on [our website](https://cleanplanet.io)
author | cleanplanet |
---|---|
permlink | jr5o3o647acqewa67sidxj |
category | hive-163521 |
json_metadata | {"app":"CleanPlanet_Bot/0.1"} |
created | 2020-07-07 16:47:51 |
last_update | 2020-07-07 16:47:51 |
depth | 1 |
children | 0 |
last_payout | 2020-07-14 16:47:51 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 314 |
author_reputation | 85,786,252,576,268 |
root_title | "Python Tips 5 - Webbrowser package" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 98,392,752 |
net_rshares | 0 |
Thanks for sharing a nice tutorial.I like the way you share repository with user. We are looking for people like you in our community. <sub> Your post has been submitted to be curated with @gitplait community account because this is the kind of publications we like to see in our community. </sub> Join our [Community on Hive](https://hive.blog)
author | gitplait-mod1 |
---|---|
permlink | qd3qlf |
category | hive-163521 |
json_metadata | {"users":["gitplait"],"links":["https://hive.blog"],"app":"hiveblog/0.1"} |
created | 2020-07-07 13:53:51 |
last_update | 2020-07-07 13:53:51 |
depth | 1 |
children | 0 |
last_payout | 2020-07-14 13:53:51 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 347 |
author_reputation | 64,455,719,431 |
root_title | "Python Tips 5 - Webbrowser package" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 98,390,183 |
net_rshares | 0 |
I use this after generating HTML reports, then opens it to the default browser. One thing I observed was when the local filepath is incorrect, it would open Microsoft Edge instead 🤔
author | oniemaniego |
---|---|
permlink | re-slashformotion-qd5lu1 |
category | hive-163521 |
json_metadata | {"tags":["hive-163521"],"app":"peakd/2020.07.1"} |
created | 2020-07-08 14:06:00 |
last_update | 2020-07-08 14:06:00 |
depth | 1 |
children | 1 |
last_payout | 2020-07-15 14:06:00 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 181 |
author_reputation | 79,934,267,673,603 |
root_title | "Python Tips 5 - Webbrowser package" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 98,408,355 |
net_rshares | 0 |
Linux is always the solving element
author | theophile.roos | ||||||
---|---|---|---|---|---|---|---|
permlink | re-oniemaniego-202078t181529762z | ||||||
category | hive-163521 | ||||||
json_metadata | {"tags":["esteem"],"app":"esteem/2.2.5-mobile","format":"markdown+html","community":"hive-125125"} | ||||||
created | 2020-07-08 16:15:30 | ||||||
last_update | 2020-07-08 16:15:30 | ||||||
depth | 2 | ||||||
children | 0 | ||||||
last_payout | 2020-07-15 16:15:30 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 0.000 HBD | ||||||
curator_payout_value | 0.000 HBD | ||||||
pending_payout_value | 0.000 HBD | ||||||
promoted | 0.000 HBD | ||||||
body_length | 36 | ||||||
author_reputation | 2,082,796,838,634 | ||||||
root_title | "Python Tips 5 - Webbrowser package" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 HBD | ||||||
percent_hbd | 10,000 | ||||||
post_id | 98,410,163 | ||||||
net_rshares | 0 |