当前位置: 首页>>代码示例>>Python>>正文


Python Ghost.click方法代码示例

本文整理汇总了Python中ghost.Ghost.click方法的典型用法代码示例。如果您正苦于以下问题:Python Ghost.click方法的具体用法?Python Ghost.click怎么用?Python Ghost.click使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ghost.Ghost的用法示例。


在下文中一共展示了Ghost.click方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: download

# 需要导入模块: from ghost import Ghost [as 别名]
# 或者: from ghost.Ghost import click [as 别名]
    def download():
        from ghost import Ghost

        ghost = Ghost(wait_timeout=timeout, download_images=False, display=False)
        ghost.open(url)
        ghost.click(b"#fn_stat")
        ghost.wait_for_text("总播放数:")
        return ghost.content
开发者ID:hackerzpf,项目名称:youku,代码行数:10,代码来源:youku.py

示例2: get_excede_html

# 需要导入模块: from ghost import Ghost [as 别名]
# 或者: from ghost.Ghost import click [as 别名]
def get_excede_html():
	result = 'unknown'
	usage_page_html = ''
	username, password = load_auth_info()
	#print "ghost initialized..."
	ghost = Ghost(wait_timeout=50, log_level='DEBUG', download_images=False)
	
	#Check for FAIL: no internet access
	try:
		page,resources = ghost.open('https://my.exede.net/usage')
	except Exception as e:
		print e.message
		result = e.message
		ghost.exit()
		return usage_page_html, result

	ghost.wait_for_page_loaded()

	if ghost.exists(".form-control.input-lg.required[name=IDToken1]"):
		print "Login found"
	else:
		print "Login not found"
		result = 'Can\'t find login box on website'
		ghost.exit()
		return usage_page_html, result

	print "Filling in field values"
	ghost.set_field_value(".form-control.input-lg.required[name=IDToken1]",username)
	ghost.set_field_value(".form-control.input-lg.required[name=IDToken2]",password)
	print "Clicking form button"
	ghost.click('.btn.btn-info.btn-lg.pull-right.col-lg-4[name="Login.Submit"]')
	print "Waiting for page to load"
	ghost.wait_for_page_loaded()

	try:
		if ghost.wait_for_selector('.amount-used',timeout=60):
			print "Found the amount used..."
			result = 'OK'
		else:
			print "Did not find the amount used"	
			result = 'OK'
			#ghost.exit()
			#return usage_page_html, result

	except Exception as e:
		print e.message
		result = e.message

	
	usage_page_html = ghost.content.encode('ascii', 'ignore')
	
	print "Writing resulting page to disk as final_page.html"
	with open('final_page.html', 'w') as data_file:
		data_file.write(usage_page_html)
	
	ghost.exit()
	return usage_page_html, result
开发者ID:vipperofvip,项目名称:skymeter,代码行数:59,代码来源:exede.py

示例3: download

# 需要导入模块: from ghost import Ghost [as 别名]
# 或者: from ghost.Ghost import click [as 别名]
def download(url, timeout = 30):
    from ghost import Ghost

    ghost = Ghost(wait_timeout=timeout, download_images=False, display=False)
    ghost.open(url)
    ghost.click(b'.playNums')
    ghost.wait_for_text("播放量数据")
    content = ghost.content
    ghost.exit()
    return content
开发者ID:luotigerlsx,项目名称:DataAnalysis_ML,代码行数:12,代码来源:youku_ghost.py

示例4: reptile

# 需要导入模块: from ghost import Ghost [as 别名]
# 或者: from ghost.Ghost import click [as 别名]
def reptile(url):
	
	ghost = Ghost(wait_timeout=20)
	page,resources = ghost.open(url)
	result, resources = ghost.wait_for_selector("#wxmore a")
	
	from bs4 import BeautifulSoup
	c=0
	
	while True:
	    if c>=1:
	        break
	 
	    soup = BeautifulSoup(ghost.content)
	 
	    for wx in soup.find_all("h4"):
	        links = re.findall('"((http|ftp)s?://.*?)"', str(wx))
	        try:
	            #print links[0][0]
	            furl.write(links[0][0])
	            furl.write('\n')
	            furl.write('\n')
	        except:
	            pass
	        titles = re.findall('">.*?<\/a', str(wx))
	        try:
	            #print titles[0][2:-3].decode("utf-8")
	            ftitle.write(titles[0][2:-3])
	            ftitle.write('\n')
	            ftitle.write('\n')
	        except:
	            pass
	
	    for img in soup.find_all("img"):
	        imgs = re.findall('c="http://img01\.st.*" s', str(img))
	        try:
	            #print imgs[0][3:-3].replace('amp;','')
	            fimg.write(imgs[0][3:-3].replace('amp;',''))
	            fimg.write('\n')
	            fimg.write('\n')
	        except:
	            pass
	 
	    page, resources = ghost.evaluate(
	        """
	        var div1 = document.getElementById("wxbox");
	        div1.innerHTML = '';
	        """)
	    ghost.click("#wxmore a")
	    result, resources = ghost.wait_for_selector(".wx-rb3")
	 
	    c=c+1
	    pass
	pass
开发者ID:cnfrankzhou,项目名称:Reptile,代码行数:56,代码来源:reptile.py

示例5: GAGetter

# 需要导入模块: from ghost import Ghost [as 别名]
# 或者: from ghost.Ghost import click [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()
开发者ID:haxoza,项目名称:stathacker,代码行数:53,代码来源:getter.py

示例6: Ghost

# 需要导入模块: from ghost import Ghost [as 别名]
# 或者: from ghost.Ghost import click [as 别名]
sys.setdefaultencoding("utf-8")
 
from ghost import Ghost
ghost = Ghost(wait_timeout=20)
 
url="http://weixin.sogou.com/gzh?openid=oIWsFt8JDv7xubXz5E3U41T0eFbk"
page,resources = ghost.open(url)
result, resources = ghost.wait_for_selector("#wxmore a")
 
from bs4 import BeautifulSoup
c=0
while True:
    if c>=30:
        break
 
    soup = BeautifulSoup(ghost.content)
 
    for wx in soup.find_all("h4"):
        print wx
 
    page, resources = ghost.evaluate(
        """
        var div1 = document.getElementById("wxbox");
        div1.innerHTML = '';
        """)
    ghost.click("#wxmore a")
    result, resources = ghost.wait_for_selector(".wx-rb3")
 
    c=c+1
    pass
开发者ID:tmyyss,项目名称:python,代码行数:32,代码来源:study_ghost.py

示例7:

# 需要导入模块: from ghost import Ghost [as 别名]
# 或者: from ghost.Ghost import click [as 别名]
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"

ghost.click('div.venue_block > a:first-child')
ghost.wait_for_page_loaded()

print "Status: 6"

ghost.click("input[value='check in']", expect_loading=True)
time.sleep(10)
#ghost.wait_for_page_loaded()

开发者ID:jooray,项目名称:foursquare_checkin,代码行数:30,代码来源:foursquare.py

示例8: Crawler

# 需要导入模块: from ghost import Ghost [as 别名]
# 或者: from ghost.Ghost import click [as 别名]
class Crawler():
    def __init__(self, target_url):
        self.max_depth = 0 #0为单页面
        self.ghost = Ghost(wait_timeout=page_timeout, display=True, download_images=False)
        dvwa_security(self.ghost, 'low')
        self.base_url = base(target_url)
        self.result = {target_url: []} #字典保存所有url及其参数
        self.__page_crawler(target_url, 0)

    def __add_url(self, all_url, url):
        pre_url, paras = url_extract(url)
        if pre_url not in self.result and pre_url.startswith(self.base_url):
            self.result[pre_url] = set(self.result) | set(paras)
            all_url.append(url)
            #print 'add', url

    def __page_crawler(self, target_url, depth):
        if depth > self.max_depth:
            return
        try:
            self.ghost.open(target_url)
            print 'open', depth, target_url
        except TimeoutError:
            print 'timeout'
            return

        all_url = [] #所有链接
        url_queue = [] #临时
        soup = BeautifulSoup(str(self.ghost.content), from_encoding='utf-8') #编码问题
        '''
        #获取点击事件
        self.ghost.wait_timeout = 8 #模拟点击时
        events = soup.find_all(onclick=True)
        for e in events:
            try:
                continue_flag = 0
                for k in ['return false;', 'logout']:
                    if e['onclick'].lower().find(k) != -1:
                        continue_flag = 1
                        break
                if continue_flag == 1:
                    continue
                if e['onclick'] not in url_queue:
                    url_queue.append(e['onclick'])
                    self.ghost.click(\'''*[onclick = "%s"]\''' % e['onclick'], expect_loading=True)
                    url, resources = self.ghost.evaluate('window.location.href')
                    if url != target_url:
                        self.__add_url(all_url, str(url))
                        self.ghost.open(target_url)
            except TimeoutError:
                print e['onclick'], 'no page loaded'
            except:
                print traceback.format_exc()
        self.ghost.wait_timeout = page_timeout

        #获取超链接
        array = soup.find_all('a')
        for a in array:
            try:
                continue_flag = 0
                url = standard(target_url, a['href'])
                for k in ['javascript:;', 'return false;', 'logout']:
                    if url.lower().find(k) != -1:
                        continue_flag = 1
                        break
                if continue_flag == 1:
                    continue
                if url.startswith('http'):
                    self.__add_url(all_url, url) #url
                elif url not in url_queue and not url.startswith('#'):
                    url_queue.append(url)
                    self.ghost.click(\'''a[href="%s"]\''' % url, expect_loading=True)
                    url, resources = self.ghost.evaluate('window.location.href')
                    if url != target_url:
                        self.__add_url(all_url, str(url))
                        self.ghost.open(target_url)
            except TimeoutError:
                print url, 'failed'
            except KeyError:
                pass
            except:
                print url, traceback.format_exc()
        '''
        #获取表单
        target_forms = []
        forms = soup.find_all('form')
        for input, form in enumerate(forms):
            names = []
            inputs = form.find_all('input', type=lambda type: type == 'text' or type == 'password'or not type)
            texts = form.find_all('textarea')
            for input in inputs:
                try:
                    names.append(input['name'])
                except KeyError:
                    pass
            for text in texts:
                try:
                    names.append(text['name'])
                except KeyError:
                    pass
#.........这里部分代码省略.........
开发者ID:surpassly,项目名称:front,代码行数:103,代码来源:backup.py

示例9: type

# 需要导入模块: from ghost import Ghost [as 别名]
# 或者: from ghost.Ghost import click [as 别名]
# -*- coding:utf-8 -*-
from ghost import Ghost
from toString import toString
import codecs
import time
ghost=Ghost(wait_timeout=60)
page,resources=ghost.open('http://login.benshouji.com/')
ghost.wait_for_page_loaded()
result, resources = ghost.fill("form", {"uname": "0a1rzbqwjfhg85","pwd": "123456789"})
page,resources=ghost.click("#loginbtn", expect_loading=True)
print 'login succeed'
page,resources=ghost.open('http://fahao.benshouji.com/holiday/5605004484/')
ghost.wait_for_page_loaded()
#ghost.click('#linghao')
result, resources=ghost.evaluate('document.getElementById("linghao").click();')
#ghost.fill('')
result,resources=ghost.evaluate('document,getElementById("")')
time.sleep(30)
print result
print resources
print type(ghost.cookies)
fp=codecs.open('test.html','w','utf-8')
fp.write(ghost.content)
#print ghost.content
开发者ID:zhangymJLU,项目名称:work1,代码行数:26,代码来源:geCode.py

示例10: Ghost

# 需要导入模块: from ghost import Ghost [as 别名]
# 或者: from ghost.Ghost import click [as 别名]
from ghost import Ghost

ghost = Ghost()
#page, resources = ghost.open('https://www.redfin.com/')
page, resources = ghost.open('https://www.redfin.com/city/18607/AZ/Tempe')
ghost.click('#downloadLink')
开发者ID:slopez15,项目名称:ASU-CREU2016,代码行数:8,代码来源:redfin.py

示例11: Ghost

# 需要导入模块: from ghost import Ghost [as 别名]
# 或者: from ghost.Ghost import click [as 别名]
from ghost import Ghost

url = "http://www.ebay.com/"
gh = Ghost()

# We load the main page of ebay
page, resources = gh.open(url, wait_onload_event=True)

# Full the main bar and click on the search button
gh.set_field_value("#gh-ac", "plane")
gh.click("#gh-btn")

# Wait for the next page
gh.wait_for_selector("#e1-15")

# Save the image of the screen
gh.capture_to("plane.png")
开发者ID:imclab,项目名称:pylines,代码行数:19,代码来源:example.py


注:本文中的ghost.Ghost.click方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。