使用Python启动浏览器(Chromium)并更改URL [英] Using Python to start a browser (Chromium) and change the url

查看:439
本文介绍了使用Python启动浏览器(Chromium)并更改URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个脚本,以使其可以更改活动进程的url。



例如,我正在使用以下方式启动浏览器:

 浏览器= Popen([ chromium, http://www.google.com])

在X间隔之后,我想更改浏览器的网址。



<我已经尝试了一些事情来获得这个结果,但是到目前为止没有成功。 (stdin.write / put(PIPE)等)。

  browser = sh.Command('uzbl-browser') (print_events = True,config ='-',uri = current_browser_url,_bg = True)
browser.process.stdin.put('uri http://www.google.nl'+'\n')

我希望您能为此提供帮助。



问候



Wesley。

解决方案

我建议使用 selenium 自动执行此过程,尽管您也可以使用 webbrowser

 从selenium.webdriver导入*; 

chrome = Chrome()#创建浏览器
chrome.get('http://www.google.com')


I am trying to write a script that makes it possible to change the url of an active process.

So for instance, I am starting my browser using:

browser = Popen(["chromium", "http://www.google.com"])

After an X interval I want to change the url of browser.

I've tried allot of things to get this result but nothing has succeeded so far. (stdin.write / put (PIPE) etc etc.).

browser = sh.Command('uzbl-browser')(print_events=True, config='-', uri=current_browser_url, _bg=True)
browser.process.stdin.put('uri http://www.google.nl' + '\n')

I'm hoping you can help me out with this.

Regards,

Wesley.

解决方案

I recommend using selenium to automate this process although you could use webbrowser too:

from selenium.webdriver import *;

chrome = Chrome() # create browser
chrome.get('http://www.google.com')

这篇关于使用Python启动浏览器(Chromium)并更改URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆