Esempio n. 1
0
def openPage(page) :
  global browser
  if not browser :
    browser = twill.get_browser()
    redirect_output("/dev/null")
  
  browser.go("http://localhost:%s%s" % (PORT, page))
  return browser.get_html()
Esempio n. 2
0
def openPage(page):
    global browser
    if not browser:
        browser = twill.get_browser()
        redirect_output("/dev/null")

    browser.go("http://localhost:%s%s" % (PORT, page))
    return browser.get_html()
Esempio n. 3
0
    def search (self, key_word):
        mybrowser.go( self.base_url )

        #Silent Mode default True'
        if self.silent:
            mybrowser.redirect_error("/dev/null")       
            mybrowser.redirect_output("/dev/null")
        try:    
            mybrowser.formclear("1")#reset For first Form
            mybrowser.fv("1", "q", key_word) #change First Form with Key Word
            mybrowser.submit("btnG") #Click Search in Google not
            print "Request Finished"
        except HTTPError, httpe:
            print "\nError: %s\n%s\n%s" % (httpe.code, httpe.msg, httpe.__doc__)
Esempio n. 4
0
 def __init__ ( self ):
     #self.base_url     = "http://www.webcamps.com.br/"
     #self.base_url     = "http://localhost"
     self.base_url     = "http://www.scarpan.com.br"
     self.links   = []
     self.visited = ["%s/" % self.base_url]
     browsers = ["webdriver.firefox", "webdriver.chrome", "zope.testbrowser"]
     self.browser =  Browser(browsers[randint(0,2)])
     #Redirect Messages
     firefox.redirect_error("/tmp/twill.err")
     firefox.redirect_output("/tmp/twill.out")  
     firefox.go( self.base_url )
     self.browser.visit( self.base_url )
     self.extractAllLinks ( firefox.showlinks() )
     self.visitAllLinks()
Esempio n. 5
0
import twill.commands as t
from pyquery import PyQuery
import re
import urllib, urllib2
import sys

t.redirect_output("/dev/null")


class AccountBannedError(RuntimeError):
    def __init__(self, message):
        RuntimeError.__init__(self, message)


def logInToReddit(username, password):
    try:
        urllib2.urlopen("http://reddit.com/user/%s" % username).read()
    except urllib2.HTTPError as e:
        if "404" in str(e):
            raise AccountBannedError("User %s has been banned." % username)

    t.go("http://www.reddit.com/")
    t.fv(2, "user", username)
    t.fv(2, "passwd", password)
    t.submit()
    return isLoggedIn()


def isLoggedIn():
    t.go("http://reddit.com/")
    userBar = PyQuery(t.show())(".user").text()