本文整理汇总了Python中login.Login.login方法的典型用法代码示例。如果您正苦于以下问题:Python Login.login方法的具体用法?Python Login.login怎么用?Python Login.login使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类login.Login
的用法示例。
在下文中一共展示了Login.login方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: verify_cookie
# 需要导入模块: from login import Login [as 别名]
# 或者: from login.Login import login [as 别名]
def verify_cookie(cls):
with open(path.join(path.abspath('.'),'cookie.txt'),'r+',encoding='utf-8') as f:
cookie = f.read()
if cookie:
cookies = json.loads(cookie)
return cls(cookie=cookies)
else:
l = Login()
l.login()
return cls(cookie=Spider.verify_cookie())
示例2: test
# 需要导入模块: from login import Login [as 别名]
# 或者: from login.Login import login [as 别名]
def test(self):
storage = {}
a = Admin(storage)
l = Login(storage)
a.addUser('fred', 's3cr3t')
u = l.login('fred', 's3cr3t')
self.assertTrue(u is not None)
u2 = l.login('fred', 's3cr3t')
self.assertTrue(u is u2)
u3 = l.login('fred', 'password')
self.assertTrue(u3 is None)
示例3: test
# 需要导入模块: from login import Login [as 别名]
# 或者: from login.Login import login [as 别名]
class test(object):
def __init__(self):
self.username = 'You account'
self.password = 'You password'
self.userlogin = Login()
self.userlogin.set_login_info(self.username,self.password)
self.login_url = 'http://3g.renren.com/friendlist.do?&sid=PwyGFaedzB81fFMISfrmve&kxlp77&htf=3'
#设置一个计数,作为文件名字
self.count = 1
self.id_count = 1
def get_page(self,url):
return self.userlogin.login(url)
def download_friends_page(self):
'''这个函数将所有的好友列表页面保存下来'''
#首先保存第一个页面
page = self.get_page(self.login_url)
store_friends = StoreFriends()
store_friends.store(self.count,page)
#因为显示总共有43页,所以设置range(44)就好
for i in range(44):
#输出一个提示
print 'The %d page is saved successfully!' % self.count
get_friends = GetFriends()
#获取下一个页面的链接
url = get_friends.get_next_url(page)
if url != None:
#将下一页链接作为抓取url
page = self.get_page(url)
store_friends = StoreFriends()
self.count += 1
#保存页面
store_friends.store(self.count,page)
else:
continue
def store_friends_info(self):
#总共有43个页面
for i in range(43):
#读取文件信息
file_obj = file('friends/' + str(self.count) + '.html','r')
page = file_obj.read()
file_obj.close()
#将page传给FriendsInfo模块解析
get_friend_info = FriendInfo(page)
id_list = get_friend_info.get_id()
name_list = get_friend_info.get_name()
url_list = get_friend_info.get_url()
#实例化数据库操作模块对象
engine = Engine()
#一个页面只有5个好友信息,所以range(5)
for i in range(5):
#测试打印
print "%d : %d : %s : %s" % (self.id_count,int(id_list[i]),str(name_list[i]),str(url_list[i]))
info_list = [self.id_count,int(id_list[i]),str(name_list[i]),str(url_list[i])]
try:
#调用数据库模块的插入方法
user_id = info_list[0]
account_id = info_list[1]
user_name = info_list[2]
profile_url = info_list[3]
engine.insert("insert into friends_info values('%d','%d','%s','%s');" % (user_id,account_id,user_name,profile_url))
except Exception,e:
print e
self.id_count += 1
self.count += 1
示例4: login
# 需要导入模块: from login import Login [as 别名]
# 或者: from login.Login import login [as 别名]
def login():
_login = Login()
r_session = _login.create_session()
if not _login.isLogin():
_login.login()
return r_session
示例5: login
# 需要导入模块: from login import Login [as 别名]
# 或者: from login.Login import login [as 别名]
def login():
login_ = Login()
session = login_.create_session()
if not login_.isLogin():
login_.login()
return session
示例6: CrawlerData
# 需要导入模块: from login import Login [as 别名]
# 或者: from login.Login import login [as 别名]
continue
item['content'] = content
if not bObj.pubStartupLongWeibo(item):
continue
#wObj.pubStartupFeed(item)
return True
return False
if __name__ == '__main__':
cObj = CrawlerData()
mObj = Mongo(CONF)
wObj = Weibo(APP_KEY , APP_SECRET , TOKEN)
lObj = Login()
cookie = lObj.login(USERNAME,PASSWORD)
if not cookie:
print 'error'
sys.exit()
cookie = re.sub('domain.*?[;,]','',cookie)
cookie = re.sub('[Hh]ttponly,','',cookie)
cookie = re.sub('path=/;','',cookie)
cookie +=';'
print cookie
bObj = Blog(cObj,cookie,wObj)
fObj = open('/home/erik/technewsrss/flag2','r')
flag = int(fObj.read().strip())
if flag < 3:
if not startupNews(cObj,mObj,bObj):
示例7: reload
# 需要导入模块: from login import Login [as 别名]
# 或者: from login.Login import login [as 别名]
# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf8')
# 添加库路径
currentPath = sys.path[0].replace('unit', '')
sys.path.append(currentPath)
sys.path.append(currentPath + r'codes')
sys.path.append(currentPath + r'codes\parser')
sys.setrecursionlimit(1000000) # 为了适应知乎上的长答案,需要专门设下递归深度限制。。。
from baseClass import *
from login import Login
from init import Init
init = Init()
SqlClass.set_conn(init.getConn())
login = Login()
login.login()