Opening Up a Web Browser with Python
来源:互联网 发布:淘宝客优惠卷源码下载 编辑:程序博客网 时间:2024/04/29 19:15
Start by importing webbrowser
:
import
webbrowser
Next, simply call the webbrowser.open(url,new=0,) function
. The variable, url
, stands for the link you would like python to open using your default web browser (this will need to be of type ‘string’). The second variable, new
, represents the method the browser will attempt to use in order to open the url: 1) new=0 means the url is opened in the same browser window if possible, 2) new=1 means a new browser window is opened if possible, and 3) new=2 means a new browser page (“tab”) is opened if possible.
Here’s an example:
webbrowser.
open
(url
=
'http://en.wikipedia.org/wiki/Main_Page'
,new
=
2
)
Calling:
webbrowser.get()
with no arguments will display the default browser.
Lastly, if you seek to open a webpage using python through the command line, you can achieve this by:
python -m webbrowser -t
"http://en.wikipedia.org/wiki/Main_Page"
The above ‘-t’ flag means to use a new tab, and can be switched for -n if you require a new browser window to be used instead. For more about the webbrowser module, see the documentation on their site.
- Opening Up a Web Browser with Python
- Opening URL in a browser from JavaFX Desktop Application
- chrome init a browser with cookie
- stopping popup windows in a web browser
- Beef up Web search applications with Lucene Improve searches with a more robust app from the Apach
- A browser pop-up bloker is detected.Please allow the pop-up for this site
- Programming the MSHTML Web Browser Control with C++
- Web Application Penetration testing with Google Chrome Browser
- web browser
- Opening multiple databases with SQLite
- Keep A Node.Js Server Up With Forever
- Setting up a windows PHP server with MSSQL
- How to set up a debugger with mod_rails/Passenger
- Smarten Up a Slick Login Form With CSS3
- Keep a node.js server up with Forever
- <LearnWLS> Setting Up Examples to Run with a Derby Database
- Setting Up Swagger 2 with a Spring Boot REST API
- Setting Up Swagger 2 with a Spring REST API
- webkit之RenderTheme
- 客户端javascript之脚本化文档
- !男孩忍不住内心的伤痛决定要弄清楚到底为了什么
- nginx配置
- 设计模式(6):模版方法模式
- Opening Up a Web Browser with Python
- 建本地 repo server
- 存储过程
- 四个常用且重要的数据结构
- Java中abstract类
- 【复杂网络系列】SNAP(Stanford Large Network Dataset Collection)实验数据集
- Android源码分析与系统原理:利用Java反射技术阻止通过按钮关
- 擦肩而过--至罗薇
- Build your own cryptographically safe server/client protocol