launch
启动chrome浏览器
chrome_path string
chrome.exe的路径。如果chrome安装在默认路径这个值可以是空字符串
headless bool
是否以headless模式启动
args string
启动参数,用'|'分隔
返回值
port int
启动失败返回 0,成功返回端口号
例子
chrome.launch("d:\\chrome\\chrome.exe", false, "--user-data-dir=C:\\user_data")
======================================================================
======================================================================
bind
绑定已启动的浏览器
port int
绑定launch返回的端口号
返回值
success bool
绑定成功返回true
======================================================================
======================================================================
close
关闭浏览器
======================================================================
======================================================================
get_window_state
获取浏览器的窗口状态
返回值
state string
可以是以下值
normal, minimized, maximized, fullscreen.
分别表示 正常,最小化,最大化,全屏
======================================================================
======================================================================
set_window_state
设置窗口状态
state string
参考get_window_state的返回值
======================================================================
======================================================================
get_window_position
获取窗口的位置
返回值
left|top string
======================================================================
======================================================================
set_window_position
设置窗口的位置
left int
top int
======================================================================
======================================================================
get_window_size
获取窗口大小
返回值
width|heigth string
======================================================================
======================================================================
set_window_size
设置窗口大小
width int
height int
======================================================================
======================================================================
get_all_cookies
获取所有cookie
返回值
cookies string
======================================================================
======================================================================
get_cookies
根据url获取cookies
url string
返回值
cookies string
======================================================================
======================================================================
set_cookies
设置cookies
cookies string
这个值是json类型的字符串,json格式参考get_cookies返回的值
例子
cookies = chrome.get_cookies("http://www.baidu.com")
chrome.clear_cookies()
chrome.set_cookies(cookies)
======================================================================
======================================================================
delete_cookies
删除cookies
name string
url string
domain string
======================================================================
======================================================================
clear_cookies
清除所有cookie
======================================================================
======================================================================
clear_cache
清除缓存
======================================================================
======================================================================
set_user_agent
设置user agent
user_agent string
======================================================================
======================================================================
get_tab_ids
获取所有tab的id
返回值
tab_ids string
======================================================================
======================================================================
set_tab
设置操作的tab的id
tab_id string
======================================================================
======================================================================
new_tab
打开一个新tab
url string
返回值
tab_id string
======================================================================
======================================================================
activate_tab
激活一个tab
======================================================================
======================================================================
close_tab
关闭一个tab
======================================================================
======================================================================
get_frame_ids
获取tab的所有框架id
frame_ids string
======================================================================
======================================================================
set_frame
设置框架
frame_id string
======================================================================
======================================================================
load
载入url
url string
======================================================================
======================================================================
reload
刷新网页
======================================================================
======================================================================
is_loading
判断网页是否在载入状态
返回值
result bool
======================================================================
======================================================================
get_title
获取标题
返回值
title string
======================================================================
======================================================================
get_url
获取url
返回值
url string
======================================================================
======================================================================
screenshot
截取网页图像
x int
y int
截取的起始位置
width int
height int
截取的大小,-1表示全屏截取
save_path string
保存路径
例子
result = chrome.screenshot(0, 0, -1, -1, "d:\\screenshot.png")
======================================================================
======================================================================
upload_file
设置file input的value
selector string
file input的css选择器
file_path string
文件路径
例子
chrome.upload_file("input[type=file]", "c:\\aa.png")
======================================================================
======================================================================
dialog_type
返回dialog的类型
返回值
type string
以下值之一
alert, confirm, prompt, beforeunload.
======================================================================
======================================================================
dialog_text
返回dialog的标题
返回值
text string
======================================================================
======================================================================
dialog_accept
处理dialog
accept bool
prompt_text string
======================================================================
======================================================================
key_down
�
- 1
- 2
- 3
- 4
前往页