Ejemplo n.º 1
0
def post(title, post, YVI_LOGIN, YVI_PASSWORD, YVI_USER_ID=None):
    request = ClientCookie.Request("http://yvision.kz/auth/")
    response = ClientCookie.urlopen(request)

    forms = ParseResponse(response, backwards_compat=False)
    form = forms[1]

    form.action = 'http://yvision.kz/ajax/auth/login.php'
    form['login'] = YVI_LOGIN
    form['password'] = YVI_PASSWORD
    request = form.click()
    response = ClientCookie.urlopen(request)

    request = ClientCookie.Request('http://%s.yvision.kz/manage/article/add' % YVI_LOGIN)

    #request = ClientCookie.Request('http://%s.yvision.kz/manage/article/edit/%s' % (YVI_LOGIN,POST_ID))

    response = ClientCookie.urlopen(request)
    forms = ParseResponse(response, backwards_compat=False)
    form = forms[2]

    form.action = 'http://%s.yvision.kz/ajax/post/article.php?publicate=1' % YVI_LOGIN
    form['blog_title'] = title
    form['blog_post'] = post
    form['blog_tags'] = "notag"
    if YVI_USER_ID is not None:
        form.new_control('hidden','user-id',{'id':'user-id','value':YVI_USER_ID})
    form.new_control('hidden','save',{'value':'asd'})
    form.new_control('hidden','saveexit',{'value':'asdf'})

    request = form.click()
    response = ClientCookie.urlopen(request)
Ejemplo n.º 2
0
	def run(self):
		global success
		value = getword()
		try:
			print "-"*12
			print "User:"******"Password:"******"User-agent","Mozilla/5.0 (compatible)")]
			ClientCookie.install_opener(opener)
			fp = ClientCookie.urlopen("https://www.gmail.com/")
			forms = ClientForm.ParseResponse(fp)
			form = forms[0]
			form["Email"]  = sys.argv[1] 
			form["Passwd"] = value      
			fp = ClientCookie.urlopen(form.click())
			site = fp.readlines()
			for line in site:
				if re.search("Gmail - Inbox", line):
					print "\tSuccessful Login:", value
					success =  value
					sys.exit(1)
			fp.close()
		except(socket.gaierror), msg: 
			pass
Ejemplo n.º 3
0
 def run(self):
     global success
     value = getword()
     try:
         print "-" * 12
         print "User:"******"Password:"******"User-agent", random.sample(headers, 1)[0])]
         ClientCookie.install_opener(opener)
         fp = ClientCookie.urlopen(sys.argv[1])
         forms = ClientForm.ParseResponse(fp)
         form = forms[0]
         form["username"] = sys.argv[2]
         form["password"] = value
         fp = ClientCookie.urlopen(form.click())
         site = fp.readlines()
         for line in site:
             if re.search("invalid password", line.lower()) != None:
                 print "\tSuccessful Login:"******"The maximum number of 5 login attempts has been exceeded.",
                     line):
                 print "Attempts exceeded"
         fp.close()
     except (socket.gaierror), msg:
         pass
Ejemplo n.º 4
0
	def run(self):
		global success
		value = getword()
		try:
			print "-"*12
			print "User:"******"Password:"******"User-agent", random.sample(headers,  1)[0])]
			ClientCookie.install_opener(opener)
			fp = ClientCookie.urlopen(sys.argv[1])
			forms = ClientForm.ParseResponse(fp)
			form = forms[0]
			form["username"] = sys.argv[2] 
			form["password"] = value      
			fp = ClientCookie.urlopen(form.click())
			site = fp.readlines()
			for line in site:
				if re.search("invalid password", line.lower()) != None:
					print "\tSuccessful Login:"******"The maximum number of 5 login attempts has been exceeded.",line):
					print "Attempts exceeded" 
			fp.close()
		except(socket.gaierror), msg: 
			pass
Ejemplo n.º 5
0
 def run(self):
     global success
     value = getword()
     try:
         print "-" * 12
         print "User:"******"Password:"******"User-agent", random.sample(headers, 1)[0])]
         ClientCookie.install_opener(opener)
         fp = ClientCookie.urlopen(sys.argv[1])
         forms = ClientForm.ParseResponse(fp)
         form = forms[0]
         form["user"] = sys.argv[2]
         form["pass"] = value
         fp = ClientCookie.urlopen(form.click())
         site = fp.readlines()
         for line in site:
             if re.search("Login failed.", line.lower()) != None:
                 print "\tSuccessful Login:", value
                 success = value
                 sys.exit(1)
         fp.close()
     except (socket.gaierror, urllib2.HTTPError), msg:
         print msg
         pass
Ejemplo n.º 6
0
    def loginByUser(self, user, url = None):
        res = True

        if UrlLoader.loginByUser(self, user, url) == False:
            return False;

        signinUrl = self.getUrl() + '/signin'

        try:
            cookieJar = ClientCookie.CookieJar()
            opener = ClientCookie.build_opener(
                ClientCookie.HTTPCookieProcessor(cookieJar))
            opener.addheaders = [("User-agent","Mozilla/5.0 (compatible)")]
            ClientCookie.install_opener(opener)
            fp = ClientCookie.urlopen(signinUrl)
            forms = ClientForm.ParseResponse(fp)
            fp.close()

            form = forms[0]
            form['userName'] = user.get('userName')
            form['password'] = user.get('password')

            self._cookie = ClientCookie

            fpTestOpen = ClientCookie.urlopen(form.click())
            fpTestOpen.close()

        except Exception, e:
            print('Error when login: ' + e.message)
            res = False
Ejemplo n.º 7
0
	def run(self):
		global success
		value = getword()
		try:
			print "-"*12
			print "User:"******"Password:"******"User-agent", random.sample(headers,  1)[0])]
			ClientCookie.install_opener(opener)
			fp = ClientCookie.urlopen(sys.argv[1])
			forms = ClientForm.ParseResponse(fp)
			form = forms[0]
			form["user"] = sys.argv[2] 
			form["pass"] = value      
			fp = ClientCookie.urlopen(form.click())
			site = fp.readlines()
			for line in site:
				if re.search("Login failed.", line.lower()) != None:
					print "\tSuccessful Login:", value
					success =  value
					sys.exit(1)
			fp.close()
		except(socket.gaierror, urllib2.HTTPError), msg: 
			print msg 
			pass
def grab(test=False):
    if test and os.path.exists('cache.html'):
        print "Using cached html page"
        f = open('cache.html')
        data = f.read()
        f.close()
    else:
        # Create special URL opener (for User-Agent) and cookieJar
        cookieJar = ClientCookie.CookieJar()
        opener = ClientCookie.build_opener(ClientCookie.HTTPCookieProcessor(cookieJar))
        opener.addheaders = [("User-agent","Mozilla/5.0 (compatible)")]
        ClientCookie.install_opener(opener)
        fp = ClientCookie.urlopen("http://login.yahoo.com")
        forms = ClientForm.ParseResponse(fp)
        fp.close()

        form = forms[0]
        form["login"]  = settings.YAHOOGROUPS_USERNAME
        form["passwd"] = settings.YAHOOGROUPS_PASSWORD
        fp = ClientCookie.urlopen(form.click())
        fp.close()
        fp = ClientCookie.urlopen("http://groups.yahoo.com/group/norwichfreegle/messages") # use your group
        data = ''.join(fp.readlines())
        fp.close()
    if test:
        f = open('cache.html', 'w')
        f.write(data)
        f.close()
    return data
Ejemplo n.º 9
0
def open_connection(email, password):
    '''Log in to MySpace and store login data into a global opener.'''
    # 1. Prepare a cookie jar and a global opener
    jar = ClientCookie.CookieJar()
    opener = ClientCookie.build_opener(ClientCookie.HTTPCookieProcessor(jar))
    opener.addheaders = [("User-agent","Mozilla/5.0 (compatible)")]
    ClientCookie.install_opener(opener)

    # 2. Open the Web page with the login form
    home_resp = ClientCookie.urlopen("http://www.myspace.com")
    forms = ClientForm.ParseResponse(home_resp, backwards_compat=False)
    home_resp.close()
    
    # 3. Fill the login form and submit
    login_form = forms[1]
    login_form[login_email_field] = email
    login_form[login_password_field] = password
    login_resp = ClientCookie.urlopen(login_form.click())
    result = login_resp.read()
    login_resp.close()
#    with open("exit.html", 'w') as f:
#        f.write(result)

    # 4. Check if login was successful
    try:        
        loginPatt = '"UserId":(.*?),'
        id = int(re.search(loginPatt, result).group(1))
        return id > 0
    except (TypeError, ValueError, AttributeError):
        return False
Ejemplo n.º 10
0
def post(title, text, tags, YVI_LOGIN, YVI_PASSWORD, YVI_USER_ID=None):
    request = ClientCookie.Request("http://yvision.kz/auth/")
    response = ClientCookie.urlopen(request)

    forms = ParseResponse(response, backwards_compat=False)
    form = forms[1]

    form.action = 'http://yvision.kz/ajax/auth/login.php'
    form['login'] = YVI_LOGIN
    form['password'] = YVI_PASSWORD
    request = form.click()
    response = ClientCookie.urlopen(request)

    request = ClientCookie.Request('http://%s.yvision.kz/manage/article/add' % YVI_LOGIN)

    #request = ClientCookie.Request('http://%s.yvision.kz/manage/article/edit/%s' % (YVI_LOGIN,POST_ID))

    response = ClientCookie.urlopen(request)
    forms = ParseResponse(response, backwards_compat=False)
    form = forms[2]

    form.action = 'http://%s.yvision.kz/ajax/post/article.php?publicate=1' % YVI_LOGIN
    form['blog_title'] = title
    form['blog_post'] = text
    form['blog_tags'] = tags
    if YVI_USER_ID is not None:
        form.new_control('hidden','user-id',{'id':'user-id','value':YVI_USER_ID})
    form.new_control('hidden','save',{'value':'asd'})
    form.new_control('hidden','saveexit',{'value':'asdf'})

    request = form.click()
    response = ClientCookie.urlopen(request)
Ejemplo n.º 11
0
 def Login(self):
     url = "http://bugs.gentoo.org/enter_bug.cgi?product=Gentoo%20Linux"
     forms = ParseResponse(ClientCookie.urlopen(url))
     form = forms[0]
     print forms[0]
     try:
         form["Bugzilla_login"] = self.user
         form["Bugzilla_password"] = self.password
         response = ClientCookie.urlopen(form.click("GoAheadAndLogIn"))
     except:
         #Already logged in with coookies
         pass
Ejemplo n.º 12
0
 def Login(self):
     url = "http://bugs.gentoo.org/enter_bug.cgi?product=Gentoo%20Linux"
     forms = ParseResponse(ClientCookie.urlopen(url))
     form = forms[0]
     print forms[0]
     try:
         form["Bugzilla_login"] = self.user
         form["Bugzilla_password"] = self.password
         response = ClientCookie.urlopen(form.click("GoAheadAndLogIn"))
     except:
         #Already logged in with coookies
         pass
Ejemplo n.º 13
0
def _my_faves(nbr):
	#log in to FB
	_authenticate()
	#get the ranking data
	f = ClientCookie.urlopen("http://www.facebook.com/ajax/typeahead/search/first_degree.php?__a="+_user_fb_id+"&filter=user&viewer="+_user_fb_id+"&token=&stale_ok=0")
	#print f.read()
	for n, dic in enumerate(json.loads(f.read()[9:])["payload"]["entries"]):	
		#print "".join([str(dic["uid"]),",",str(dic["index"]),",",dic["photo"]])
		if n == 0:
			continue
		usr_info = json.load(ClientCookie.urlopen("http://graph.facebook.com/"+str(dic["uid"])))
		print n+1, usr_info["name"]
		if (n+1)==int(nbr):
			return
Ejemplo n.º 14
0
 def login(self):
     # Sets the client webbrowser
     cookieJar = ClientCookie.CookieJar()
     opener = ClientCookie.build_opener(ClientCookie.HTTPCookieProcessor(cookieJar))
     opener.addheaders = [("User-agent","Mozilla/5.0 (compatible)")]
     ClientCookie.install_opener(opener)
     # Opens the login page for yahoo.com
     fp = ClientCookie.urlopen("http://login.yahoo.com")
     forms = ClientForm.ParseResponse(fp)
     fp.close()
     form = forms[0]
     form["login"] = self.name
     form["passwd"] = self.pw
     fp = ClientCookie.urlopen(form.click())
     fp.close()
Ejemplo n.º 15
0
	def login(self):
		"""
		Perform the actual login. This method takes the username and password
		passed in when the class was initialized. It then creates a dictionary
		with login information. This dictionary is passed into urllib2 to create
		a Request, which is then passed to ClientCookie.urlopen. This method
		returns a loginResponse, which is the source code from the default
		Iodine module.
		"""
		try: # Just in case we're trying to run without an Internet connection or something
			usernameKey = 'login_username' # Defines the username field name
			passwordKey = 'login_password' # Defines the password field name
			loginUrl = "https://iodine.tjhsst.edu" # Defines the URL that the request will use
			loginInformation = {usernameKey: self.username, passwordKey: self.password} # Creates a request dictionary
			loginInformation = urllib.urlencode(loginInformation) # Encode the login information.
			loginRequest = urllib2.Request(loginUrl, loginInformation) # Creates a Request that is used to login
			loginResponse = ClientCookie.urlopen(loginRequest) # Sends the login to Iodine and stores the PHP session ID.
			loginResponse = loginResponse.read() # Get the HTML/XML from Iodine.
			webpage = BeautifulSoup(loginResponse) # Set up a Beautiful Soup object
			eighthChangeUrl = webpage.find(id="menu_eighth")['href'] # Grab the eighth period change URL
			uid = eighthChangeUrl.split("uid/")[1] # Get the UID based on the eighth period change URL
			self.uid = uid # And set the uid as a class variable, effectively getting the UID for changing things
			self.isAuthenticated = True # Yes, yes we are logged in.
			return True # Yay, no error!
		except Exception, e: # If we failed for whatever reason...
			self.uid = None # Set the uid to none.
			self.isAuthenticated = False # No, no we are not.
			print e
			raise Exception("Error in Authenticator: could not log in.") # Raise an exception.
			raise IodineException("Error in Authenticator: could not log in.", "ERR_AUTHENTICATE_LOGIN") # Raise an IodineException
Ejemplo n.º 16
0
def slrLogin(userid, passwd):
    values = {'user_id': userid, 'password': passwd}
    data = urllib.urlencode(values)
    loginurl = 'http://www.slrclub.com/login/process.php'
    request = urllib2.Request(loginurl, data)
    request.add_header('Referer', 'http://www.slrclub.com/')
    response = ClientCookie.urlopen(request)
Ejemplo n.º 17
0
def _about_me():
	try:
		me_dict = json.load(ClientCookie.urlopen(url="https://graph.facebook.com/me?access_token="+token))
		for k,v in me_dict.iteritems():
			print k, "   :   ",v
	except Exception as exc:
		print exc
Ejemplo n.º 18
0
def send_message(recipient_profile, subject, body, email, password, opened=False):
    '''Send a MySpace message to recipient_profile with given subject and body.'''
    # 1. Open a connection to MySpace
    # recipient_profile = {'id': 270977337} Send to fake recipient (debug)
    if not opened:
        open_connection(email, password)
    
    # 2. Open the Web page with the mail form
    url = mail_message_URL(recipient_profile)
    form_resp = ClientCookie.urlopen(url)
    forms = ClientForm.ParseResponse(form_resp, backwards_compat=False)
    form_resp.close()
    
    # 3. Fill the form, submit, and return the result
    mail_form = forms[1]
    try:
        mail_form[mail_subject_field] = subject
        mail_form[mail_body_field] = body
        # 20090409 - Additional commands for the To: field
        mail_form.controls[2].readonly = False # assuming mail_to_field is controls[2]
        mail_form[mail_to_field] = str(recipient_profile["id"])
    except ClientForm.ControlNotFoundError, msg:
        # For instance, if there is an AWAY message (e.g., id: 47749730)
        logging.warning("Mail form not found in %s" % url)
        return None
Ejemplo n.º 19
0
    def execute(self):
		
		print "proxyFire module loaded"
		sub_urls = []
		sub_titles = []
		sub_index = 0
		plist = []
		trys = 0
		
		# Create special URL opener (for User-Agent) and cookieJar
		cookieJar = ClientCookie.CookieJar()
		opener = ClientCookie.build_opener(ClientCookie.HTTPCookieProcessor(cookieJar))
		opener.addheaders = [("User-agent","Mozilla/5.0 (compatible)")]
		ClientCookie.install_opener(opener)
		try:
			fp = ClientCookie.urlopen("http://www.proxyfire.net/forum/login.php")
			forms = ClientForm.ParseResponse(fp)
			fp.close()
		except Exception, e:
			print e
			if trys < 6:
				time.sleep(5)
				print "trying again..."
				trys += 1
			else:
				print "proxyfire.net is timing out"
				return plist;
Ejemplo n.º 20
0
	def getToken(self):
		"""
		Get an Edit Token. The MediaWiki API requires this for security
		purposes.
		"""
		token = ClientCookie.urlopen("http://en.wikipedia.org/w/api.php?action=tokens&format=xml").read().split('edittoken="')[1].split('" />')[0]
		return token
Ejemplo n.º 21
0
def grabdata(url):
#	proxy_handler = urllib2.ProxyHandler(proxy)
#	opener = urllib2.build_opener(proxy_handler)
	opener = urllib2.build_opener()
	opener.addheaders = [('User-agent', user_agent)]
	status = False
	count = 0
	data = ''
	while status == False and count < 5:
		try:
			usock = opener.open(url)
			data = usock.read()
			usock.close()
			def checkRefresh(string):
				pattern = re.compile(r'http-equiv="refresh"')
				return pattern.search(string) != None
			if checkRefresh(data):
				import ClientCookie
				sock = ClientCookie.build_opener(ClientCookie.HTTPEquivProcessor,
						 ClientCookie.HTTPRefreshProcessor
						 )
				ClientCookie.install_opener(sock)
				data = ClientCookie.urlopen(url).read()
			status = True
		except Exception, msg:
			if count == 4:
				print "error: grab %s\n%s" % (url, msg)
			sleep(count)
			count += 1
Ejemplo n.º 22
0
   def get_info(self):
       # Opens the main page of the fantasy football
       fp = ClientCookie.urlopen(self.base_url)
       lines = fp.readlines()
       fp.close()
       text = "\n".join(lines)
       with open("localfiles/homepage", 'r') as f:
           text = f.read()
       f.close()
       # Use Beautiful Soup to parse the html.
       soup = BeautifulSoup(text)
       # Finds the teams on the page
       team_info = soup.find('div', {'class':'teams'})
       if team_info is None:       # Check login
           sys.stderr.write('Error: Login failed, parser limit exceeded or authentication failure, check username & password\n')
           sys.exit(1)
       # Stores the information about the users league
       userTeams = []
       userLeagueId = []
       for info in team_info.findAll('a', {'class':'team'}):
           userTeams.append(info.string)
           userLeagueId.append(info['href'])
       self.userTeams = userTeams
       self.userLeagueId = userLeagueId
 	return (userTeams, userLeagueId)
Ejemplo n.º 23
0
 def retrieve_leagues(self, Choice):
     QuickFix = "?lhst=stand#lhststand"
     LeagueId = self.userLeagueId[Choice]
     LeagueSplit = LeagueId.split('/')
     LeagueSplit.pop()           # Truncated the end portion to get base link
     LeagueBase = "/".join(LeagueSplit)
     
     #----> Option to pick the league you want to open <------#
     fp = ClientCookie.urlopen(self.base_url + LeagueBase + QuickFix)
     lines = fp.readlines()
     fp.close()
     text = "\n".join(lines)
     # Use Beautiful Soup to parse the html
     soup = BeautifulSoup(text)
     # Finds the teams on the page
     team_info = soup.find('table',{'class' : 'gametable'})
     teams = {}
     # Gets the information on the teams in the league 
     str_list = []
     LeagueTeamIds = []
     for info in team_info.findAll('tr', {'class':{'odd','even'}}):
         temp_list = []
         for eachTeam in info.findAll('td'):
             temp_list.append(eachTeam.string)
             for moreInfo in eachTeam.findAll('a'):
                 LeagueTeamIds.append(moreInfo['href'])
         str_list.append(' '.join(temp_list))
     self.LeagueTeamIds = LeagueTeamIds
     return LeagueTeamIds, str_list
Ejemplo n.º 24
0
 def meet(self, member):
     """
     Submit "yes" for all members on the 'meet me' feature.
     Significantly increases exposure.
     """
     u = "http://www.pof.com/meetme.aspx"
     values = {
         'votea':
         '1',
         'add_id':
         member,
         'p_Id':
         member,
         'nextfive':
         "13274077,42132650,42287788,42016458,42162693,39390651,42172880,42247856,42172950"
     }
     user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
     base64string = base64.encodestring(
         '%s:%s' % (self.username, self.password)).replace('\n', '')
     self.headers = {
         'User-Agent': user_agent,
         "Authorization": "Basic %s" % base64string
     }
     self.dd = urllib.urlencode(values)
     request = urllib2.Request(u, self.dd, self.headers)
     result = ClientCookie.urlopen(request)
     #html = result.read()
     #data= BeautifulSoup.BeautifulSoup(html)
     #return data
     return
Ejemplo n.º 25
0
def clienLogin(userid, passwd):
    values = {'mb_id':userid,'mb_password':passwd}  
    data = urllib.urlencode(values)
    loginurl = 'http://clien.career.co.kr/cs2/bbs/login_check.php'
    request = urllib2.Request(loginurl, data)
    request.add_header('Referer', 'http://clien.career.co.kr/')
    request.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.29 Safari/525.13')
    response = ClientCookie.urlopen(request)
Ejemplo n.º 26
0
def getContent(page):
    url = "http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&rvlimit=1&format=xml&titles=" + \
        page.replace(" ", "_")
    print url
    pagecontent = ClientCookie.urlopen(url).read()
    flcre = re.compile(r'(?<=preserve">).*?(?=</rev>)', re.DOTALL)
    flccontent = re.findall(flcre, pagecontent)[0]
    return flccontent
Ejemplo n.º 27
0
 def UploadAttachment(self):
     import cgi
     url = "http://bugs.gentoo.org/attachment.cgi?bugid=%s&action=enter" % self.bugNbr
     forms = ParseResponse(ClientCookie.urlopen(url))
     form = forms[0]
     print form
     form["description"] = self.ebuild
     form["contenttypemethod"] = ["list"]
     form["contenttypeselection"] = ["text/plain"]
     form["comment"] = ""
     f = file(self.filename)
     form.add_file(f, "text/plain", self.ebuild)
     request = form.click()
     response2 = ClientCookie.urlopen(request)
     print "Attachment uploaded."
     print response2.read()
     print response2.info()
Ejemplo n.º 28
0
 def UploadAttachment(self):
     import cgi
     url = "http://bugs.gentoo.org/attachment.cgi?bugid=%s&action=enter" % self.bugNbr
     forms = ParseResponse(ClientCookie.urlopen(url))
     form = forms[0]
     print form
     form["description"] = self.ebuild
     form["contenttypemethod"] = ["list"]
     form["contenttypeselection"] = ["text/plain"]
     form["comment"] = ""
     f = file(self.filename)
     form.add_file(f, "text/plain", self.ebuild)
     request = form.click()
     response2 = ClientCookie.urlopen(request)
     print "Attachment uploaded."
     print response2.read()
     print response2.info()
Ejemplo n.º 29
0
def _my_wall():
	try:
		me_dict = json.load(ClientCookie.urlopen(url="https://graph.facebook.com/me/feed?limit=3&access_token="+token))
		print me_dict["data"]
		#for k,v in me_dict.iteritems():
		#	print k, "   :   ",v
	except Exception as exc:
		print exc
Ejemplo n.º 30
0
def http_get( url ):
        request = urllib2.Request( url )
        request.add_header('Referer', url)
        request.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.29 Safari/525.13')
        #response = urllib2.urlopen(request)
        response = ClientCookie.urlopen(request)

        return response
Ejemplo n.º 31
0
def ppomppuLogin(userid, passwd):
    values = {'user_id':userid,'password':passwd}
    data = urllib.urlencode(values)
    loginurl = 'http://www.ppomppu.co.kr/zboard/login_check.php'
    request = urllib2.Request(loginurl, data)
    request.add_header('Referer', 'http://www.ppomppu.co.kr/')
    response = ClientCookie.urlopen(request)
    print response.read()
Ejemplo n.º 32
0
 def get(self, page):
     """
     basic url to source to beautifulsoup method
     """
     request = urllib2.Request(page, self.dd, self.headers)
     result = ClientCookie.urlopen(request)
     html = result.read()
     data = BeautifulSoup.BeautifulSoup(html)
     return data
Ejemplo n.º 33
0
	def daumLogin(self, userid, passwd):
		self.userid = userid
		self.passwd = passwd
		values = {'id':userid,'pw':passwd,'reloginSeq':'0', } 	
		data = urllib.urlencode(values)
		loginurl = 'https://logins.daum.net/accounts/login.do'
		request = urllib2.Request(loginurl, data)
		request.add_header('Referer', 'http://m.mypeople.daum.net/')
		response = ClientCookie.urlopen(request)
Ejemplo n.º 34
0
 def get(self,page):
     """
     basic url to source to beautifulsoup method
     """
     request = urllib2.Request(page,self.dd,self.headers)
     result = ClientCookie.urlopen(request)
     html = result.read()            
     data= BeautifulSoup.BeautifulSoup(html)
     return data        
Ejemplo n.º 35
0
def _make_status(message):
	try:
		args = dict(message=message, privacy={'value':'ALL_FRIENDS'}, access_token=token)
		encoded_args = urlencode(args)
		#print "Encoded args:", encoded_args
		response = ClientCookie.urlopen("https://graph.facebook.com/"+_usr_id+"/feed?", data=encoded_args)
		return response.read()
	except Exception as exc:
		print exc
Ejemplo n.º 36
0
def _post_request(api_url, post_data):
	"""Make request using supplied parameters and return the response, unless an error occurs"""
	try:
		#make the request and return response
		response = ClientCookie.urlopen(url=api_url,data=post_data)
		return response
	except HTTPError as exc:
		#tell user the details of the error
		raise HTTPException(exc)
Ejemplo n.º 37
0
    def EnterNewBug(self):
        url = "http://bugs.gentoo.org/enter_bug.cgi?product=Gentoo%20Linux"
        forms = ParseResponse(ClientCookie.urlopen(url))
        form = forms[0]
        form["component"] = ["Ebuilds"]
        form["bug_severity"] = ["enhancement"]
        form["bug_file_loc"] = self.uri
        form["short_desc"] = self.summary
        form["comment"] = self.desc
        request = form.click()
        response2 = ClientCookie.urlopen(request)
        lines = response2.read()
        #print response2.info() web server header info

        for l in lines:
            if l.find("Submitted") != -1:
                self.bugNbr = l.split()[1]
                print "Bug number %s created." % self.bugNbr
                break
Ejemplo n.º 38
0
    def EnterNewBug(self):
        url = "http://bugs.gentoo.org/enter_bug.cgi?product=Gentoo%20Linux"
        forms = ParseResponse(ClientCookie.urlopen(url))
        form = forms[0]
        form["component"] = ["Ebuilds"]
        form["bug_severity"] = ["enhancement"]
        form["bug_file_loc"] = self.uri
        form["short_desc"] = self.summary
        form["comment"] = self.desc
        request = form.click()
        response2 = ClientCookie.urlopen(request)
        lines = response2.read()
        #print response2.info() web server header info

        for l in lines:
            if l.find("Submitted") != -1:
                self.bugNbr = l.split()[1]
                print "Bug number %s created." % self.bugNbr
                break
Ejemplo n.º 39
0
def _post_msg_to_wall(target, message):
	try:
		args = dict(message=message, access_token=token)
		encoded_args = urlencode(args)
		#print "Encoded args:", encoded_args
		response = ClientCookie.urlopen("https://graph.facebook.com/"+target+"/feed?", data=encoded_args)
		return response.read()
	except Exception as exc:
		print "EXCEPTION!!"
		print exc.read()
Ejemplo n.º 40
0
    def post_shout(self, shout):
        """
        Post a shout.

        :param shout: a Shout object
        :return:
        """
        resp = cookielib.urlopen(self._url['send_shout'], shout.post_encode())
        
        return resp.read()
Ejemplo n.º 41
0
    def get_activities(self):
        """
        Fetch the lastest activities. You must be logged in to use this method.

        :return: the HTML containing the activities divs
        """
        data = 'last=0&key=%s' % self.account.user_key
        resp = cookielib.urlopen(self._url['fetch_activity'], data)

        return resp.read().split('<script')[0]
Ejemplo n.º 42
0
def getLoginURLDataResponse(url):
    request = urllib2.Request(url)
    request.add_header('Referer', url)
    request.add_header(
        'User-Agent',
        'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.29 Safari/525.13'
    )

    response = ClientCookie.urlopen(request)
    return response
Ejemplo n.º 43
0
    def getProfileInfoAndMsg(self, member):
        """
        gets basic profile info, message history for a single user. 
        sends replies if needed.
        
        Creates log file, sorted in decreasing order of length of message history
        """
        uid, profile, msgl = member

        data = self.get(profile)
        descr = ''
        for td in data.findAll("td", {"class": "txtGrey size15"}):
            if "cm)" in td.text:
                descr = td.text.rstrip().replace('\t', '')
                descr = smart_str(
                    descr.replace('\r',
                                  ' ').replace('\n',
                                               ' ').replace('&quot;', '"'))
                break
        data = self.get(msgl)
        descr = ''
        ids, texts = self.pullThread(msgl)
        if len(ids) == 0:
            return None
        if ids[-1] != self.pid:  #need reply
            txt = texts[-1]
            txt = smart_str(txt)
            try:
                reply = self.cbot.Ask(txt)
            except:  # possible unicode errors. default to something vacuuous
                reply = self.cbot.Ask("hello i like you")
            try:  # doesnt always work, but scrub "cleverbot" from replies
                # replace "cleverbot" with "smartchick"
                reply = reply.lower().replace('clever',
                                              'smart').replace('bot', 'chick')
            except:
                pass
            new_v = self.values.copy()
            form = data.find("form")
            for inp in form.findAll("input"):
                if inp['type'] != "checkbox":
                    new_v[inp['name']] = inp['value']
            new_v["message"] = reply
            self.headers = {
                'User-Agent': self.user_agent,
                "Authorization": "Basic %s" % self.base64string
            }
            dd = urllib.urlencode(new_v)
            request = urllib2.Request("http://www.pof.com/sendmessage.aspx",
                                      dd, self.headers)
            result = ClientCookie.urlopen(request)
            html = result.read()
            ids.append(self.pid)
            texts.append(reply)
        return descr, ids, texts, msgl
Ejemplo n.º 44
0
def start():
    username = None
    password = None

    # Get the POST paramters
    if request.method == 'POST':
        username = request.form['username']
        password = request.form['password']
    else:
        username = request.args['username']
        password = request.args['password']

    # Root url for the account service
    root_url = 'https://keys.kent.edu:44220/ePROD'

    # Retrieve the login page.
    url = root_url + '/twbkwbis.P_WWWLogin'
    req = urllib2.Request(url)
    response = ClientCookie.urlopen(req)
    the_page = response.read()

    # Login into the service.
    url = root_url + '/twbkwbis.P_ValLogin'
    values = {'sid': username, 'PIN': password}
    data = urllib.urlencode(values)
    req = urllib2.Request(url, data)
    response = ClientCookie.urlopen(req)
    the_page = response.read()

    # Get the HTML for the schedule page.
    url = root_url + '/bwskfshd.P_CrseSchdDetl'
    values = {'term_in': '201280'}
    data = urllib.urlencode(values)
    req = urllib2.Request(url, data)
    response = ClientCookie.urlopen(req)
    the_page = response.read()

    # Instantiate the parser and fed it some HTML.
    soup = BeautifulSoup(the_page, "lxml")

    # Return the schedule as a json.
    return simplejson.dumps(_parseSchedule(soup))
Ejemplo n.º 45
0
 def _get(self, req):
     starttime = time.time()
     try:
         self.response = ResponseRecorder(ClientCookie.urlopen(req))
     except urllib2.HTTPError, e:
         # urllib2.HTTPError instances are also Response objects
         self.response = ResponseRecorder(e)
         self.response.read()
         try:
             url = req.get_full_url()
         except AttributeError:
             url = req
         raise InteractError('%s: %s' % (url, e))
Ejemplo n.º 46
0
    def uploadRun(self, email, password, files):
        '''
        '''
        def file2text(fn):
            fh = open(fn)
            fc = fh.read()
            fh.close()
            return fc

        upload_url = self.url + '/add_run.php'
        success = True
        backupdir = self.getConfigDataFromFile()[2]

        if not self.isLoggedIn:
            self.isLoggedIn = self.webLogin(email, password)

        if self.isLoggedIn:

            for full_path in files:
                self.logger.info("uploading file %s" % full_path)
                path, fname = os.path.split(full_path)

                if self.isNewFile(fname):

                    m = Multipart()
                    m.field('public_run', 'checked')
                    m.field('MAX_FILE_SIZE', '14000000')
                    m.file(
                        'runfile', fname, file2text(full_path),
                        {'Content-Type': 'application/x-www-form-urlencoded'})
                    ct, body = m.get()

                    request = urllib2.Request(upload_url,
                                              headers={'Content-Type': ct},
                                              data=body)
                    reply = ClientCookie.urlopen(request)
                    file_uploaded = 'Runometer: Show Run' in reply.read()

                    if file_uploaded:
                        self.logFileUploaded(fname)
                        shutil.copy(full_path, backupdir)

                    success = success * file_uploaded

                else:
                    self.logger.info(
                        "File %s already uploaded in some previous session" %
                        fname)

        return success
Ejemplo n.º 47
0
	def getLastMsg(self, channel, lastseq):
		if not self.lastseq.has_key(channel) :
			self.lastseq[channel] = 0
		values = {'pkKey':channel,'dummy':time.time()}
		if lastseq > 0:
			values['lastSeq'] = '%d'%lastseq
		data = urllib.urlencode(values)
		action = 'http://m.mypeople.daum.net/mypeople/xmlhttp/getLastMessage.do'
		request = urllib2.Request(action, data)
		request.add_header('Referer', 'http://m.mypeople.daum.net/')
		response = ClientCookie.urlopen(request)

		ret = response.read()[2:-2]
		return self.parseMsg(channel, ret)
Ejemplo n.º 48
0
	def msgSend(self, channel, msg):
		#http://m.mypeople.daum.net/mypeople/xmlhttp/getPrevMessage.do?
		values = {'pkKey':channel,'dummy':'testsfa','content':msg , 'lastSeq':'%d'%self.lastseq[channel]} 	
		data = urllib.urlencode(values)
		action = 'http://m.mypeople.daum.net/mypeople/xmlhttp/getSendMessage.do'
		request = urllib2.Request(action, data)
		request.add_header('Referer', 'http://m.mypeople.daum.net/')
		response = ClientCookie.urlopen(request)
		ret = response.read()[2:-2]

		ret = response.read()[2:-2]
		data = self.parseMsg(channel, ret)
		for msg in data:
			self.dispatchMsg(channel, msg)
		return data
Ejemplo n.º 49
0
    def webLogin(self, email, password):
        '''
        '''
        good_login_text = 'Welcome Back to Runometer'
        login_url = self.url + '/login.php'

        post_data = {'username': email, 'passwd': password, 'rememberme': True}
        headers = {'Content-type': 'application/x-www-form-urlencoded'}
        return_value = None

        if not self.testing:

            request = urllib2.Request(login_url,
                                      headers=headers,
                                      data=urllib.urlencode(post_data))
            reply = ClientCookie.urlopen(request)
            return_value = good_login_text in reply.read()

        return return_value
Ejemplo n.º 50
0
            for header in request.header_items():
                self.httpout.write("%s: %s\n" % header[:])

            self.httpout.write('\n')

        return request

    def http_response(self, request, response):
        if __debug__:
            code, msg, hdrs = response.code, response.msg, response.info()
            self.httpout.write("HTTP/1.x %s %s\n" % (code, msg))
            self.httpout.write(str(hdrs))

        return response

    https_request = http_request
    https_response = http_response


# Example
cjar = ClientCookie.LWPCookieJar()
opener = ClientCookie.build_opener(
    ClientCookie.HTTPCookieProcessor(cjar),
    ClientCookie.HTTPRefererProcessor(),
    HTTPMyDebugProcessor(),
)
ClientCookie.install_opener(opener)
response = ClientCookie.urlopen("http://www.google.com")
#...
Ejemplo n.º 51
0
def ping_url(url, n=1):
    request = ClientCookie.Request(url)
    for i in xrange(0,n):
        response = ClientCookie.urlopen(request)
Ejemplo n.º 52
0
def getLoginURLDataResponse(url):
    request = urllib2.Request(url)
    request.add_header('Referer', url)
    response = ClientCookie.urlopen(request)
    return response
Ejemplo n.º 53
0
import sys
sys.path.append('ClientCookie-1.0.3')
import ClientCookie
sys.path.append('ClientForm-0.1.17')
import ClientForm

# Create special URL opener (for User-Agent) and cookieJar
cookieJar = ClientCookie.CookieJar()

opener = ClientCookie.build_opener(ClientCookie.HTTPCookieProcessor(cookieJar))
opener.addheaders = [("User-agent","Mozilla/5.0 (compatible)")]
ClientCookie.install_opener(opener)
fp = ClientCookie.urlopen("https://app-us.meallogger.com/#/login")
forms = ClientForm.ParseResponse(fp)
fp.close()

# print forms on this page
for form in forms:
    print("***************************")
    print (form)

form = forms[0]
form["login"]  = "******" # use your userid
form["passwd"] = "password"      # use your password
fp = ClientCookie.urlopen(form.click())
fp.close()
fp = ClientCookie.urlopen("http://groups.yahoo.com/group/mygroup") # use your group
fp.readlines()
fp.close()
Ejemplo n.º 54
0
def getLoginURLDataResponse(url):
    request = urllib2.Request(url)
    request.add_header('Referer', url)
    request.add_header('User-Agent', 'Mozilla/4.0 (compatible;)')
    response = ClientCookie.urlopen(request)
    return response
Ejemplo n.º 55
0
import sys
sys.path.append('ClientCookie-1.0.3')
import ClientCookie
sys.path.append('ClientForm-0.1.17')
import ClientForm

# Create special URL opener (for User-Agent) and cookieJar
cookieJar = ClientCookie.CookieJar()

opener = ClientCookie.build_opener(ClientCookie.HTTPCookieProcessor(cookieJar))
opener.addheaders = [("User-agent", "Mozilla/5.0 (compatible)")]
ClientCookie.install_opener(opener)
fp = ClientCookie.urlopen("http://login.yahoo.com")
forms = ClientForm.ParseResponse(fp)
fp.close()

# print forms on this page
for form in forms:
    print "***************************"
    print form

form = forms[0]
form["login"] = "******"  # use your userid
form["passwd"] = "password"  # use your password
fp = ClientCookie.urlopen(form.click())
fp.close()
fp = ClientCookie.urlopen(
    "http://groups.yahoo.com/group/mygroup")  # use your group
fp.readlines()
fp.close()