本文整理汇总了Python中ghost.Ghost.fire_on方法的典型用法代码示例。如果您正苦于以下问题:Python Ghost.fire_on方法的具体用法?Python Ghost.fire_on怎么用?Python Ghost.fire_on使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ghost.Ghost
的用法示例。
在下文中一共展示了Ghost.fire_on方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: heroku
# 需要导入模块: from ghost import Ghost [as 别名]
# 或者: from ghost.Ghost import fire_on [as 别名]
def heroku(api_key, year, month):
ghost = None
file_path = '/tmp/heroku_invoice_%d-%d.png' % (year, month)
if os.path.exists(file_path):
os.remove(file_path)
# TODO: make dimensions configurable? Automatic (is that possible?)?
ghost = Ghost(viewport_size=(1000, 1600))
ghost.wait_timeout = 20
ghost.open('https://id.heroku.com/login')
ghost.fill("form", dict(email="", password=api_key))
ghost.fire_on("form", "submit", expect_loading=True)
ghost.open('https://dashboard.heroku.com/invoices/%s/%s' % (year, month))
ghost.capture_to(file_path)
return file_path
示例2: GAGetter
# 需要导入模块: from ghost import Ghost [as 别名]
# 或者: from ghost.Ghost import fire_on [as 别名]
class GAGetter(object):
def __init__(self, email, password):
self.email = email
self.password = password
self.ghost = Ghost(wait_timeout=20)
def test(self):
self.sign_in()
self.go_to_realtime_site()
sleep(10)
print 'COUNTER: {0}'.format(self.get_counter())
def sign_in(self):
page, resources = self.ghost.open(
'http://www.google.com/analytics/index.html')
self.ghost.wait_for_text('Analytics')
self.ghost.wait_for_selector('a.secondary-button')
self.ghost.click('a.secondary-button')
self.ghost.wait_for_text("Can't access your account?")
self._fill_signin_form()
self.ghost.wait_for_text('All Accounts')
def _fill_signin_form(self):
result, resources = self.ghost.fill(
"form", {
"Email": self.email,
"Passwd": self.password
}
)
page, resources = self.ghost.fire_on(
"form", "submit", expect_loading=True)
self.ghost.wait_for_page_loaded()
def go_to_realtime_site(self):
m = re.search(
r"#report/visitors-overview/([a-z0-9]+)/",
self.ghost.content
)
self.ghost.evaluate(
"window.location.href = '#realtime/rt-overview/{0}/'".format(
m.group(1)
)
)
self.ghost.wait_for_text('Right now')
return self.ghost.content
def get_counter(self):
d = pq(self.ghost.content)
return d('#ID-overviewCounterValue').html()
示例3: __init__
# 需要导入模块: from ghost import Ghost [as 别名]
# 或者: from ghost.Ghost import fire_on [as 别名]
class KuKlueCrawler:
# Class 생성자, id, pw로 KuKlue 로그인 시도
def __init__(self, id, pw, displayFlag = False, download_images=False, prevent_download=["css"]):
# 새 Ghost instance를 만들어서 사용합니다.
self.ghost = Ghost(display = displayFlag, wait_timeout = 60)
self.currentPage = None
self.login(id, pw)
# Class 소멸자
def __del__(self):
self.ghost.exit()
del self.ghost
# 요청한 url 접속
def openPage(self, url):
page, resource = self.ghost.open(url)
self.ghost.wait_for_page_loaded()
self.currentPage = url
return page, resource
# Login 하는 함수
def login(self, id, pw):
page, resource = self.openPage('http://klue.kr/')
self.ghost.evaluate("""
(function() {
document.getElementById('mb_id').value = '%s';
document.getElementById('mb_pw').value = '%s';
document.getElementsByClassName('login')[0].click();
})();
""" % (id, pw), expect_loading = True)
return page, resource
# 특정 index에 대해 lecture page 접속
def main_search(self, query=None, lectureNum=-1):
if query is not None:
self.ghost.wait_for_selector('#topBar_search')
self.ghost.fill("#sform", { "query": query })
page, resource = self.ghost.fire_on('#sform', 'submit', expect_loading = True)
if lectureNum != -1:
page, resource = self.openPage('http://klue.kr/lecture.php?no='+str(lectureNum))
return page, resource
示例4: exit
# 需要导入模块: from ghost import Ghost [as 别名]
# 或者: from ghost.Ghost import fire_on [as 别名]
exit(2)
else:
username = sys.argv[1]
password = sys.argv[2]
placename = sys.argv[3]
print "Status: 1"
page, resources = ghost.open('https://foursquare.com/mobile/login?continue=%2Fmobile%2F')
ghost.wait_for_page_loaded()
print "Status: 2"
result, resources = ghost.set_field_value("input[name=username]", username)
result, resources = ghost.set_field_value("input[name=password]", password)
page, resources = ghost.fire_on("form", "submit", expect_loading=True)
ghost.wait_for_page_loaded()
print "Status: 3"
page, resources = ghost.open('https://foursquare.com/mobile/checkin')
ghost.wait_for_page_loaded()
print "Status: 4"
result, resources = ghost.set_field_value("input[name=q]", placename)
page, resources = ghost.fire_on("form", "submit", expect_loading=True)
ghost.wait_for_page_loaded()
print "Status: 5"
示例5: Ghost
# 需要导入模块: from ghost import Ghost [as 别名]
# 或者: from ghost.Ghost import fire_on [as 别名]
#!/usr/bin/python
from ghost import Ghost
import argparse
# ghost nicely wraps a headless, WebKit browser, and loads pages that require javascript
ghost = Ghost()
ghost.open('http://duckduckgo.com/')
ghost.wait_for_selector('input[name=q]')
ghost.fill("#search_form_homepage", {'q': 'beer'})
ghost.fire_on("#search_form_homepage",
"submit",
expect_loading=True)
ghost.wait_for_selector('#r1-0')
result, _resources = ghost.evaluate(
"document.getElementById('r1-0').innerHTML;")
print result
示例6: Ghost
# 需要导入模块: from ghost import Ghost [as 别名]
# 或者: from ghost.Ghost import fire_on [as 别名]
import secrets
import time
from ghost import Ghost
ghost = Ghost()
page, resources = ghost.open('https://my.ecofactor.com/mobile/login.html')
result, resources = ghost.fill('form', {
'j_username': secrets.username,
'j_password': secrets.password
})
page, resources = ghost.fire_on('form', 'submit')
#page, resources = ghost.fire_on('form', 'submit', expect_loading=True)
page, resources = ghost.wait_for_page_loaded()
ghost.capture_to("/tmp/foo.png")
print page.http_status
#print resources
示例7: RunExport
# 需要导入模块: from ghost import Ghost [as 别名]
# 或者: from ghost.Ghost import fire_on [as 别名]
def RunExport():
ghost = Ghost(viewport_size=(1200, 2400), display=False, wait_timeout=30, cache_dir=CACHE_DIRECTORY)#, log_level=logging.ERROR
#
#login_password
#submit.x
#submit
page, resources = ghost.open('https://www.paypal.com/ie/cgi-bin/webscr?cmd=_login-run')
result, resources = ghost.fill("form[name=login_form]", {
"login_email": PAYPAL_USERNAME,
"login_password": PAYPAL_PASSWORD
})
page, resources = ghost.fire_on("form[name=login_form]", "submit", expect_loading=True)
result, resources = ghost.wait_for_page_loaded()
#wait for 10 seconds
#time.sleep(10)
page, resources = ghost.open('https://www.paypal.com/ie/cgi-bin/webscr?cmd=_account')
result, resources = ghost.wait_for_text("Welcome, %s" % PAYPAL_NAME)
getHistoryListing(ghost)
first_run = True
#get the next url
#print ghost.evaluate('document.querySelectorAll("#tableWrapperID .pagination:nth-child(1) a.btnLink");')[0]
nav_links_eval = """
var links = document.querySelectorAll(".pagination a.btnLink");
links.length;
"""
nav_links = ghost.evaluate(nav_links_eval)
page_count = START_AT_PAGE
transaction_count = 0
if page_count > 0:
transaction_count = page_count * 20
goToPage(ghost,page_count)
#transaction_list_url = resources[0].url
#print transaction_list_url
while nav_links[0] > 0 or first_run==True:
first_run = False
page_count = page_count + 1
filteredlisting_export = os.path.join(EXPORT_DIRECTORY,'filteredhistory%d.png' % page_count)
if not os.path.isfile(filteredlisting_export):
ghost.capture_to(filteredlisting_export, selector="body")
transaction_urls = ghost.evaluate("""
var links = document.querySelectorAll("#transactionTable tr.primary td.detailsNoPrint a");
var listRet = [];
for (var i=0; i<links.length; i++){
listRet.push(links[i].href);
}
listRet;
""")
for transaction_href in transaction_urls[0]:
transaction_count = transaction_count + 1
#print urllib.unquote(transaction_href)
page, resources = ghost.open(urllib.unquote(transaction_href))
ghost.wait_for_page_loaded()
payee_name = None
date_string = None
date = ghost.evaluate("""
document.querySelectorAll("#historyMiniLog tbody tr")[2].querySelectorAll('td')[0].innerHTML;
""")
if date and date[0]:
date_string = date[0].replace(' ','')
payee = ghost.evaluate("""
document.querySelectorAll("#historyMiniLog tbody tr")[2].querySelectorAll('td')[1].innerHTML;
""")
if payee and payee[0]:
payee_name = safeFilename(payee[0].replace(' ',''))
if payee_name and date_string:
date_object = datetime.strptime(date_string, '%d-%b-%Y')
date_string=datetime.strftime(date_object,'%Y-%m-%d')
print 'page %d transaction %d [%s - %s]' % (page_count, transaction_count, date_string, payee_name)
purchasedetails_export = os.path.join(EXPORT_DIRECTORY,'%s_%s_%s.png' % (date_string,payee_name,transaction_count ))
if not os.path.isfile(purchasedetails_export):
print '\t\tsaving to %s' % purchasedetails_export
ghost.capture_to(purchasedetails_export, selector="#xptContentMain")
else:
print '\t\tAlready saved to %s' % purchasedetails_export
else:
purchasedetails_export = os.path.join(EXPORT_DIRECTORY,'no date and payee - page-%d_ transaction %d.png' % (page_count,transaction_count ))
print '\t\tsaving to %s' % purchasedetails_export
if not os.path.isfile(purchasedetails_export):
#.........这里部分代码省略.........
示例8: type
# 需要导入模块: from ghost import Ghost [as 别名]
# 或者: from ghost.Ghost import fire_on [as 别名]
html = ghost.content.encode('utf-8');
#print type(html.encode('utf8'))
page = etree.HTML(html)
cityOption = page.xpath(u"//select[@id='ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder1_selCity']")[0]
cities = cityOption.xpath("./option/@value")
shopList = []
f2 = open('yamaha_location2.txt','a')
for city in cities:
if city != '':
print city
result, resources = ghost.fill("#aspnetForm", {
"ctl00$ctl00$ContentPlaceHolder1$ContentPlaceHolder1$selCity": city,
"sss": "1"
})
ghost.fire_on("#aspnetForm", "submit", expect_loading=True)
html = ghost.content.encode('utf-8');
page = etree.HTML(html)
dealer = page.xpath(u"//table[@id='dealerTD1']")[0]
for shop in dealer.xpath('./tbody/tr'):
name = shop.xpath('./td[1]/a/text()')[0].encode('utf8').strip()
address = shop.xpath('./td[2]/text()')[0].encode('utf8').strip()
response = urllib2.urlopen(mapUrl + address)
responseJSON = response.read()
jsonObj = json.loads(responseJSON)
loc = jsonObj['results'][0]['geometry']['location']
location = str(loc['lat']) + ';' + str(loc['lng'])
print location
phone = shop.xpath('./td[3]/text()')[0].encode('utf8').strip()
shopString = name + ';' + address + ';' + location + ';' + phone + '\n'
shopList.append(shopString)
示例9: Ghost
# 需要导入模块: from ghost import Ghost [as 别名]
# 或者: from ghost.Ghost import fire_on [as 别名]
from ghost import Ghost
from local import settings
ghost = Ghost()
page, resources = ghost.open('http://www.economist.com/audio-edition/latest')
result, resources = ghost.fill("#user-login", {
"name": settings['email_address'],
"pass": settings['password']
})
print 'logging in'
page, resources = ghost.fire_on("#user-login", "submit", expect_loading=True)
download_url, resources = ghost.evaluate(
"document.querySelector('.audio-issue-full-download-link > a').getAttribute('href');")
print 'download url {}'.format(download_url)
示例10: Ghost
# 需要导入模块: from ghost import Ghost [as 别名]
# 或者: from ghost.Ghost import fire_on [as 别名]
ghost = Ghost(wait_timeout=timeout)
# Получаем страницу с формой логина
page, resources = ghost.open(add_page)
assert page.http_status == 200 and 'loginForm' in ghost.content
# Заполняем форму логина
ghost.fill('#loginForm',
{
'login': user,
'password': passwd
}
)
page, resources = ghost.fire_on('#loginForm',
'submit',
expect_loading=True)
assert page.http_status == 200 and u'Выход' in ghost.content
# Получаем страницу с формой добавления файла
page, resources = ghost.open(add_page)
assert page.http_status == 200 and 'formulaire' in ghost.content
# Заполняем форму добавления файла
ghost.fill('#formulaire', {'file': args.file})
page, resources = ghost.fire_on('#formulaire',
'submit',
expect_loading=True)
assert page.http_status == 200 and 'myform' in ghost.content
# Заполняем данные о подкасте