PK \,+Gm$! ghost-py-latest/.buildinfo# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config:
tags:
PK \,+G ghost-py-latest/objects.inv# Sphinx inventory version 2
# Project: Ghost.py
# Version: 0.2.2
# The remainder of this file is compressed using zlib.
xڥn }H5zL;L@48 8MYҩiŧDZmo`*"=#`Qvm:v-#K5̀BtҶFW¦(r2ݢx,nAgv )r+\:,wd FKCXUk1y S)XԖ6P)IxN3=w+d!Jԍ)k2p8h@EX&9J욬R(Q &?$mħ<ٰt5)o?@Q
SaL!Y^8#Qs}ȓfgtG.ȥ1yĂ
k|z\=`221Lɍ]zr2 PK \,+GkZ Z ghost-py-latest/index.html
Ghost.py 0.2.2 documentation
Ghost.py
ghost.py
ghost.py is a webkit web client written in python:
from ghost import Ghost
ghost = Ghost ()
with ghost . start () as session :
page , extra_resources = session . open ( "http://jeanphix.me" )
assert page . http_status == 200 and 'jeanphix' in page . content
Installation
ghost.py requires either PySide (preferred) or PyQt Qt bindings:
pip install pyside
pip install ghost.py --pre
OSX:
brew install qt
mkvirtualenv foo
pip install -U pip # make sure pip is current
pip install PySide
pyside_postinstall.py -install
pip install Ghost.py
API
Ghost
class ghost.
Ghost
( log_level=30, log_handler=<logging.StreamHandler object>, plugin_path=['/usr/lib/mozilla/plugins'], defaults=None )
Ghost manages a Qt application.
Parameters:
log_level – The optional logging level.
log_handler – The optional logging handler.
plugin_path – Array with paths to plugin directories
(default [‘/usr/lib/mozilla/plugins’])
defaults – The defaults arguments to pass to new child sessions.
start
( **kwargs )
Starts a new Session .
Session
class ghost.
Session
( ghost , user_agent='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML , like Gecko) Chrome/15.0.874.121 Safari/535.2' , wait_timeout=8 , wait_callback=None , display=False , viewport_size=(800 , 600) , ignore_ssl_errors=True , plugins_enabled=False , java_enabled=False , javascript_enabled=True , download_images=True , show_scrollbars=True , network_access_manager_class=<class 'ghost.ghost.NetworkAccessManager'> , web_page_class=<class 'ghost.ghost.GhostWebPage'> )
Session manages a QWebPage.
Parameters:
ghost – The parent Ghost instance.
user_agent – The default User-Agent header.
wait_timeout – Maximum step duration in second.
wait_callback – An optional callable that is periodically
executed until Ghost stops waiting.
log_level – The optional logging level.
log_handler – The optional logging handler.
display – A boolean that tells ghost to displays UI.
viewport_size – A tuple that sets initial viewport size.
ignore_ssl_errors – A boolean that forces ignore ssl errors.
plugins_enabled – Enable plugins (like Flash).
java_enabled – Enable Java JRE.
download_images – Indicate if the browser should download images
call
( *args , **kwargs )
Call method on element matching given selector.
Parameters:
selector – A CSS selector to the target element.
method – The name of the method to call.
expect_loading – Specifies if a page loading is expected.
capture
( region=None , selector=None , format=None )
Returns snapshot as QImage.
Parameters:
region – An optional tuple containing region as pixel
coodinates.
selector – A selector targeted the element to crop on.
format – The output image format.
capture_to
( path , region=None , selector=None , format=None )
Saves snapshot as image.
Parameters:
path – The destination path.
region – An optional tuple containing region as pixel
coodinates.
selector – A selector targeted the element to crop on.
format – The output image format.
clear_alert_message
( )
Clears the alert message
click
( *args , **kwargs )
Click the targeted element.
Parameters:
selector – A CSS3 selector to targeted element.
btn – The number of mouse button.
0 - left button,
1 - middle button,
2 - right button
confirm
( *args , **kwds )
Statement that tells Ghost how to deal with javascript confirm().
Parameters: confirm – A boolean or a callable to set confirmation.
content
Returns current frame HTML as a string.
Parameters: to_unicode – Whether to convert html to unicode or not
cookies
Returns all cookies.
delete_cookies
( )
Deletes all cookies.
evaluate
( *args , **kwargs )
Evaluates script in page frame.
Parameters: script – The script to evaluate.
evaluate_js_file
( path , encoding='utf-8' , **kwargs )
Evaluates javascript file at given path in current frame.
Raises native IOException in case of invalid file.
Parameters:
path – The path of the file.
encoding – The file’s encoding.
exists
( selector )
Checks if element exists for given selector.
Parameters: string – The element selector.
exit
( )
Exits all Qt widgets.
fill
( *args , **kwargs )
Fills a form with provided values.
Parameters:
selector – A CSS selector to the target form to fill.
values – A dict containing the values.
fire
( *args , **kwargs )
Fire event on element at selector
Parameters:
selector – A selector to target the element.
event – The name of the event to trigger.
frame
( selector=None )
Set main frame as current main frame’s parent.
Parameters: frame – An optional name or index of the child to descend to.
global_exists
( global_name )
Checks if javascript global exists.
Parameters: global_name – The name of the global.
hide
( )
Close the webview.
load_cookies
( cookie_storage , keep_old=False )
load from cookielib’s CookieJar or Set-Cookie3 format text file.
Parameters:
cookie_storage – file location string on disk or CookieJar
instance.
keep_old – Don’t reset, keep cookies not overridden.
open
( address , method='get' , headers={} , auth=None , body=None , default_popup_response=None , wait=True , timeout=None , client_certificate=None , encode_url=True , user_agent=None )
Opens a web page.
Parameters:
address – The resource URL.
method – The Http method.
headers – An optional dict of extra request hearders.
auth – An optional tuple of HTTP auth (username, password).
body – An optional string containing a payload.
default_popup_response – the default response for any confirm/
alert/prompt popup from the Javascript (replaces the need for the with
blocks)
:param wait: If set to True (which is the default), this
method call waits for the page load to complete before
returning. Otherwise, it just starts the page load task and
it is the caller’s responsibilty to wait for the load to
finish by other means (e.g. by calling wait_for_page_loaded()).
:param timeout: An optional timeout.
:param client_certificate An optional dict with “certificate_path” and
“key_path” both paths corresponding to the certificate and key files
:param encode_url Set to true if the url have to be encoded
:param user_agent An option user agent string.
:return: Page resource, and all loaded resources, unless wait
is False, in which case it returns None.
print_to_pdf
( path , paper_size=(8.5 , 11.0) , paper_margins=(0 , 0 , 0 , 0) , paper_units=None , zoom_factor=1.0 )
Saves page as a pdf file.
See qt4 QPrinter documentation for more detailed explanations
of options.
Parameters:
path – The destination path.
paper_size – A 2-tuple indicating size of page to print to.
paper_margins – A 4-tuple indicating size of each margin.
paper_units – Units for pager_size, pager_margins.
zoom_factor – Scale the output content.
prompt
( *args , **kwds )
Statement that tells Ghost how to deal with javascript prompt().
Parameters: value – A string or a callable value to fill in prompt.
region_for_selector
( selector )
Returns frame region for given selector as tuple.
Parameters: selector – The targeted element.
save_cookies
( cookie_storage )
Save to cookielib’s CookieJar or Set-Cookie3 format text file.
Parameters: cookie_storage – file location string or CookieJar instance.
set_field_value
( *args , **kwargs )
Sets the value of the field matched by given selector.
Parameters:
selector – A CSS selector that target the field.
value – The value to fill in.
blur – An optional boolean that force blur when filled in.
set_proxy
( type_ , host='localhost' , port=8888 , user='' , password='' )
Set up proxy for FURTHER connections.
Parameters:
type – proxy type to use: none/default/socks5/https/http.
host – proxy server ip or host name.
port – proxy port.
set_viewport_size
( width , height )
Sets the page viewport size.
Parameters:
width – An integer that sets width pixel count.
height – An integer that sets height pixel count.
show
( )
Show current page inside a QWebView.
wait_for
( condition , timeout_message , timeout=None )
Waits until condition is True.
Parameters:
condition – A callable that returns the condition.
timeout_message – The exception message on timeout.
timeout – An optional timeout.
wait_for_alert
( timeout=None )
Waits for main frame alert().
Parameters: timeout – An optional timeout.
wait_for_page_loaded
( timeout=None )
Waits until page is loaded, assumed that a page as been requested.
Parameters: timeout – An optional timeout.
wait_for_selector
( selector , timeout=None )
Waits until selector match an element on the frame.
Parameters:
selector – The selector to wait for.
timeout – An optional timeout.
wait_for_text
( text , timeout=None )
Waits until given text appear on main frame.
Parameters:
text – The text to wait for.
timeout – An optional timeout.
wait_while_selector
( selector , timeout=None )
Waits until the selector no longer matches an element on the frame.
Parameters:
selector – The selector to wait for.
timeout – An optional timeout.
PK \,+Gv2% % ! ghost-py-latest/_static/basic.css/*
* basic.css
* ~~~~~~~~~
*
* Sphinx stylesheet -- basic theme.
*
* :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
/* -- main layout ----------------------------------------------------------- */
div.clearer {
clear: both;
}
/* -- relbar ---------------------------------------------------------------- */
div.related {
width: 100%;
font-size: 90%;
}
div.related h3 {
display: none;
}
div.related ul {
margin: 0;
padding: 0 0 0 10px;
list-style: none;
}
div.related li {
display: inline;
}
div.related li.right {
float: right;
margin-right: 5px;
}
/* -- sidebar --------------------------------------------------------------- */
div.sphinxsidebarwrapper {
padding: 10px 5px 0 10px;
}
div.sphinxsidebar {
float: left;
width: 230px;
margin-left: -100%;
font-size: 90%;
}
div.sphinxsidebar ul {
list-style: none;
}
div.sphinxsidebar ul ul,
div.sphinxsidebar ul.want-points {
margin-left: 20px;
list-style: square;
}
div.sphinxsidebar ul ul {
margin-top: 0;
margin-bottom: 0;
}
div.sphinxsidebar form {
margin-top: 10px;
}
div.sphinxsidebar input {
border: 1px solid #98dbcc;
font-family: sans-serif;
font-size: 1em;
}
div.sphinxsidebar #searchbox input[type="text"] {
width: 170px;
}
div.sphinxsidebar #searchbox input[type="submit"] {
width: 30px;
}
img {
border: 0;
max-width: 100%;
}
/* -- search page ----------------------------------------------------------- */
ul.search {
margin: 10px 0 0 20px;
padding: 0;
}
ul.search li {
padding: 5px 0 5px 20px;
background-image: url(file.png);
background-repeat: no-repeat;
background-position: 0 7px;
}
ul.search li a {
font-weight: bold;
}
ul.search li div.context {
color: #888;
margin: 2px 0 0 30px;
text-align: left;
}
ul.keywordmatches li.goodmatch a {
font-weight: bold;
}
/* -- index page ------------------------------------------------------------ */
table.contentstable {
width: 90%;
}
table.contentstable p.biglink {
line-height: 150%;
}
a.biglink {
font-size: 1.3em;
}
span.linkdescr {
font-style: italic;
padding-top: 5px;
font-size: 90%;
}
/* -- general index --------------------------------------------------------- */
table.indextable {
width: 100%;
}
table.indextable td {
text-align: left;
vertical-align: top;
}
table.indextable dl, table.indextable dd {
margin-top: 0;
margin-bottom: 0;
}
table.indextable tr.pcap {
height: 10px;
}
table.indextable tr.cap {
margin-top: 10px;
background-color: #f2f2f2;
}
img.toggler {
margin-right: 3px;
margin-top: 3px;
cursor: pointer;
}
div.modindex-jumpbox {
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
margin: 1em 0 1em 0;
padding: 0.4em;
}
div.genindex-jumpbox {
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
margin: 1em 0 1em 0;
padding: 0.4em;
}
/* -- general body styles --------------------------------------------------- */
a.headerlink {
visibility: hidden;
}
h1:hover > a.headerlink,
h2:hover > a.headerlink,
h3:hover > a.headerlink,
h4:hover > a.headerlink,
h5:hover > a.headerlink,
h6:hover > a.headerlink,
dt:hover > a.headerlink,
caption:hover > a.headerlink,
p.caption:hover > a.headerlink,
div.code-block-caption:hover > a.headerlink {
visibility: visible;
}
div.body p.caption {
text-align: inherit;
}
div.body td {
text-align: left;
}
.field-list ul {
padding-left: 1em;
}
.first {
margin-top: 0 !important;
}
p.rubric {
margin-top: 30px;
font-weight: bold;
}
img.align-left, .figure.align-left, object.align-left {
clear: left;
float: left;
margin-right: 1em;
}
img.align-right, .figure.align-right, object.align-right {
clear: right;
float: right;
margin-left: 1em;
}
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left;
}
.align-center {
text-align: center;
}
.align-right {
text-align: right;
}
/* -- sidebars -------------------------------------------------------------- */
div.sidebar {
margin: 0 0 0.5em 1em;
border: 1px solid #ddb;
padding: 7px 7px 0 7px;
background-color: #ffe;
width: 40%;
float: right;
}
p.sidebar-title {
font-weight: bold;
}
/* -- topics ---------------------------------------------------------------- */
div.topic {
border: 1px solid #ccc;
padding: 7px 7px 0 7px;
margin: 10px 0 10px 0;
}
p.topic-title {
font-size: 1.1em;
font-weight: bold;
margin-top: 10px;
}
/* -- admonitions ----------------------------------------------------------- */
div.admonition {
margin-top: 10px;
margin-bottom: 10px;
padding: 7px;
}
div.admonition dt {
font-weight: bold;
}
div.admonition dl {
margin-bottom: 0;
}
p.admonition-title {
margin: 0px 10px 5px 0px;
font-weight: bold;
}
div.body p.centered {
text-align: center;
margin-top: 25px;
}
/* -- tables ---------------------------------------------------------------- */
table.docutils {
border: 0;
border-collapse: collapse;
}
table caption span.caption-number {
font-style: italic;
}
table caption span.caption-text {
}
table.docutils td, table.docutils th {
padding: 1px 8px 1px 5px;
border-top: 0;
border-left: 0;
border-right: 0;
border-bottom: 1px solid #aaa;
}
table.field-list td, table.field-list th {
border: 0 !important;
}
table.footnote td, table.footnote th {
border: 0 !important;
}
th {
text-align: left;
padding-right: 5px;
}
table.citation {
border-left: solid 1px gray;
margin-left: 1px;
}
table.citation td {
border-bottom: none;
}
/* -- figures --------------------------------------------------------------- */
div.figure {
margin: 0.5em;
padding: 0.5em;
}
div.figure p.caption {
padding: 0.3em;
}
div.figure p.caption span.caption-number {
font-style: italic;
}
div.figure p.caption span.caption-text {
}
/* -- other body styles ----------------------------------------------------- */
ol.arabic {
list-style: decimal;
}
ol.loweralpha {
list-style: lower-alpha;
}
ol.upperalpha {
list-style: upper-alpha;
}
ol.lowerroman {
list-style: lower-roman;
}
ol.upperroman {
list-style: upper-roman;
}
dl {
margin-bottom: 15px;
}
dd p {
margin-top: 0px;
}
dd ul, dd table {
margin-bottom: 10px;
}
dd {
margin-top: 3px;
margin-bottom: 10px;
margin-left: 30px;
}
dt:target, .highlighted {
background-color: #fbe54e;
}
dl.glossary dt {
font-weight: bold;
font-size: 1.1em;
}
.field-list ul {
margin: 0;
padding-left: 1em;
}
.field-list p {
margin: 0;
}
.optional {
font-size: 1.3em;
}
.sig-paren {
font-size: larger;
}
.versionmodified {
font-style: italic;
}
.system-message {
background-color: #fda;
padding: 5px;
border: 3px solid red;
}
.footnote:target {
background-color: #ffa;
}
.line-block {
display: block;
margin-top: 1em;
margin-bottom: 1em;
}
.line-block .line-block {
margin-top: 0;
margin-bottom: 0;
margin-left: 1.5em;
}
.guilabel, .menuselection {
font-family: sans-serif;
}
.accelerator {
text-decoration: underline;
}
.classifier {
font-style: oblique;
}
abbr, acronym {
border-bottom: dotted 1px;
cursor: help;
}
/* -- code displays --------------------------------------------------------- */
pre {
overflow: auto;
overflow-y: hidden; /* fixes display issues on Chrome browsers */
}
td.linenos pre {
padding: 5px 0px;
border: 0;
background-color: transparent;
color: #aaa;
}
table.highlighttable {
margin-left: 0.5em;
}
table.highlighttable td {
padding: 0 0.5em 0 0.5em;
}
div.code-block-caption {
padding: 2px 5px;
font-size: small;
}
div.code-block-caption code {
background-color: transparent;
}
div.code-block-caption + div > div.highlight > pre {
margin-top: 0;
}
div.code-block-caption span.caption-number {
padding: 0.1em 0.3em;
font-style: italic;
}
div.code-block-caption span.caption-text {
}
div.literal-block-wrapper {
padding: 1em 1em 0;
}
div.literal-block-wrapper div.highlight {
margin: 0;
}
code.descname {
background-color: transparent;
font-weight: bold;
font-size: 1.2em;
}
code.descclassname {
background-color: transparent;
}
code.xref, a code {
background-color: transparent;
font-weight: bold;
}
h1 code, h2 code, h3 code, h4 code, h5 code, h6 code {
background-color: transparent;
}
.viewcode-link {
float: right;
}
.viewcode-back {
float: right;
font-family: sans-serif;
}
div.viewcode-block:target {
margin: -1px -10px;
padding: 0 10px;
}
/* -- math display ---------------------------------------------------------- */
img.math {
vertical-align: middle;
}
div.body div.math p {
text-align: center;
}
span.eqno {
float: right;
}
/* -- printout stylesheet --------------------------------------------------- */
@media print {
div.document,
div.documentwrapper,
div.bodywrapper {
margin: 0 !important;
width: 100%;
}
div.sphinxsidebar,
div.related,
div.footer,
#top-link {
display: none;
}
}PK \,+G[ $ ghost-py-latest/_static/pygments.css.highlight .hll { background-color: #ffffcc }
.highlight { background: #eeffcc; }
.highlight .c { color: #408090; font-style: italic } /* Comment */
.highlight .err { border: 1px solid #FF0000 } /* Error */
.highlight .k { color: #007020; font-weight: bold } /* Keyword */
.highlight .o { color: #666666 } /* Operator */
.highlight .cm { color: #408090; font-style: italic } /* Comment.Multiline */
.highlight .cp { color: #007020 } /* Comment.Preproc */
.highlight .c1 { color: #408090; font-style: italic } /* Comment.Single */
.highlight .cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #A00000 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #FF0000 } /* Generic.Error */
.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.highlight .gi { color: #00A000 } /* Generic.Inserted */
.highlight .go { color: #333333 } /* Generic.Output */
.highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.highlight .gt { color: #0044DD } /* Generic.Traceback */
.highlight .kc { color: #007020; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #007020 } /* Keyword.Pseudo */
.highlight .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #902000 } /* Keyword.Type */
.highlight .m { color: #208050 } /* Literal.Number */
.highlight .s { color: #4070a0 } /* Literal.String */
.highlight .na { color: #4070a0 } /* Name.Attribute */
.highlight .nb { color: #007020 } /* Name.Builtin */
.highlight .nc { color: #0e84b5; font-weight: bold } /* Name.Class */
.highlight .no { color: #60add5 } /* Name.Constant */
.highlight .nd { color: #555555; font-weight: bold } /* Name.Decorator */
.highlight .ni { color: #d55537; font-weight: bold } /* Name.Entity */
.highlight .ne { color: #007020 } /* Name.Exception */
.highlight .nf { color: #06287e } /* Name.Function */
.highlight .nl { color: #002070; font-weight: bold } /* Name.Label */
.highlight .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
.highlight .nt { color: #062873; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #bb60d5 } /* Name.Variable */
.highlight .ow { color: #007020; font-weight: bold } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #208050 } /* Literal.Number.Bin */
.highlight .mf { color: #208050 } /* Literal.Number.Float */
.highlight .mh { color: #208050 } /* Literal.Number.Hex */
.highlight .mi { color: #208050 } /* Literal.Number.Integer */
.highlight .mo { color: #208050 } /* Literal.Number.Oct */
.highlight .sb { color: #4070a0 } /* Literal.String.Backtick */
.highlight .sc { color: #4070a0 } /* Literal.String.Char */
.highlight .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */
.highlight .s2 { color: #4070a0 } /* Literal.String.Double */
.highlight .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */
.highlight .sh { color: #4070a0 } /* Literal.String.Heredoc */
.highlight .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */
.highlight .sx { color: #c65d09 } /* Literal.String.Other */
.highlight .sr { color: #235388 } /* Literal.String.Regex */
.highlight .s1 { color: #4070a0 } /* Literal.String.Single */
.highlight .ss { color: #517918 } /* Literal.String.Symbol */
.highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */
.highlight .vc { color: #bb60d5 } /* Name.Variable.Class */
.highlight .vg { color: #bb60d5 } /* Name.Variable.Global */
.highlight .vi { color: #bb60d5 } /* Name.Variable.Instance */
.highlight .il { color: #208050 } /* Literal.Number.Integer.Long */PK V,+G ! ghost-py-latest/_static/minus.pngPNG
IHDR pHYs tIME<8 tEXtComment ̖ PLTE)))`MZ IDATc
a=0V-a ĺ IENDB`PK V,+GPu
u
# ghost-py-latest/_static/comment.pngPNG
IHDR a
OiCCPPhotoshop ICC profile xڝSgTS=BKKoR RB&*! J!QEEȠQ,
!{kּ>H3Q5B.@
$p d!s# ~<<+" x M0B\t8K @zB @F&S