本文整理汇总了Python中Login.login方法的典型用法代码示例。如果您正苦于以下问题:Python Login.login方法的具体用法?Python Login.login怎么用?Python Login.login使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Login
的用法示例。
在下文中一共展示了Login.login方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Crawler
# 需要导入模块: import Login [as 别名]
# 或者: from Login import login [as 别名]
def Crawler(number, weibo_url):
Login.login() #首先进行模拟登录
fp4 = open("chinese_weibo.txt","w+") #初始化写入文件
for n in range(number):
n = n + 1
url = 'http://weibo.com/' + weibo_url + '?is_search=0&visible=0&is_tag=0&profile_ftype=1&page=' + str(n)
# url = 'http://s.weibo.com/weibo/%s&Refer=index'%weibo_url
print U"爬取URL:",url
content = Getraw_HTML.get_rawHTML(url) # 调用获取网页源文件的函数执行
print u"获取第 %d 成功 , 并写入到 raw_html.txt"%n
Gettext_CH.Handel(content, fp4) # 调用解析页面的函数
print u"获取第 %d 微博内容成功, 并写入到 chinese_weibo.txt"%n
#time.sleep(1)
fp4.close()
########## 数据爬取完毕!
# 对爬取到的微博进行去重处理
fp = open('chinese_weibo.txt', 'r')
contents = []
for content in fp.readlines():
content = content.strip()
contents.append(content)
fp.close()
set_contents = list(set(contents))
set_contents.sort(key=contents.index)
fp_handel = open('chinese_weibo.txt', 'w+')
for content in set_contents:
fp_handel.write(content)
fp_handel.write('\n')
fp_handel.close()
示例2: setUp
# 需要导入模块: import Login [as 别名]
# 或者: from Login import login [as 别名]
def setUp(self):
global login_cookie
login_cookie = None
login_cookie = Login.login()
if [] in login_cookie:
raise AssertionError("Login is not successful.")
else:
print "Login is done successfully."
示例3: testLogin
# 需要导入模块: import Login [as 别名]
# 或者: from Login import login [as 别名]
def testLogin(self):
br=Login.login(self.driver,self.baseurl)
log=ResultLog.resultLog()
time.sleep(10)
result=br.find_element_by_css_selector("a.red").is_displayed()
print result
if result:
log.info("用户已登录2")
else:
log.info(u"用户登录失败")
示例4: menu
# 需要导入模块: import Login [as 别名]
# 或者: from Login import login [as 别名]
def menu(host, T, t_host):
while True:
print ("Scegli azione PEER:\nlogin\t - Login\nquit\t - Quit\n\n")
choice = input()
if (choice == "login" or choice == "l"):
t_host, sessionID = logi.login(host, t_host)
if sessionID != bytes(const.ERROR_LOG, "ascii"):
tfunc.success("Session ID: " + str(sessionID, "ascii"))
listPartOwned = {}
daemonThreadP = daemon.PeerDaemon(host, listPartOwned)
daemonThreadP.setName("DAEMON PEER")
daemonThreadP.setDaemon(True)
daemonThreadP.start()
waitingDownload = []
while True:
if len(waitingDownload) == 0:
print ("\n\nScegli azione PEER LOGGATO:\nadd\t - Add File\nsearch\t - Search and Download\nlogout\t - Logout\n\n")
choice_after_log = input()
if (choice_after_log == "add" or choice_after_log == "a"):
add.add(host, sessionID, t_host, listPartOwned)
elif (choice_after_log == "search" or choice_after_log == "s"):
src.search(sessionID, host, t_host, listPartOwned, waitingDownload)
elif (choice_after_log == "logout" or choice_after_log == "l"):
if (logo.logout(host, t_host, sessionID) > 0):
break
else:
tfunc.error("Wrong Choice!")
else:
time.sleep(1)
else:
tfunc.error("Errore Login")
elif (choice == "quit" or choice == "q"):
if T:
logo.quit(host)
break
else:
tfunc.error("Wrong Choice")
示例5: test_add_load
# 需要导入模块: import Login [as 别名]
# 或者: from Login import login [as 别名]
def test_add_load(self):
"""QQ登录测试"""
width = self.driver.get_window_size()['width']
height = self.driver.get_window_size()['height']
Login.login(self)
sleep(4)
self.driver.find_element_by_android_uiautomator('new UiSelector().description("帐户及设置")').click()
sleep(1)
self.driver.find_element_by_android_uiautomator('new UiSelector().description("设置")').click()
sleep(2)
self.driver.find_element_by_xpath('//android.widget.TextView[contains(@text, "帐号管理")]').click()
self.driver.swipe(width / 2, height / 2, width / 2, height / 4, 1000)
self.driver.find_element_by_name("退出当前帐号").click()
self.driver.find_element_by_xpath('//android.widget.TextView[contains(@text, "确认退出")]').click()
try:
sleep(2)
self.driver.swipe(width / 2, height / 2, 114, height / 2, 1000)
sleep(2)
except Exception as e:
print(e)
示例6: check
# 需要导入模块: import Login [as 别名]
# 或者: from Login import login [as 别名]
def check(bot, update):
print(users)
if UP_States.get(str(update.message.chat_id) , -1) == REGISTERED:
try:
login = Login.login(users[str(update.message.chat_id)])
print (str(update.message.from_user.first_name) + ' => Check')
login.encryptUserPassword()
login.logIn()
html = login.html
scpr = Scrapper.scrapper(html)
scpr.make()
bot.sendMessage(update.message.chat_id, text=scpr.text)
print (str(update.message.from_user.first_name) + ' => Succecfull')
except BaseException as ex :
print (ex.args);
bot.sendMessage(update.message.chat_id, text="An error has occured")
else:
bot.sendMessage(update.message.chat_id, text="Please set up username and password at first.")
示例7: print
# 需要导入模块: import Login [as 别名]
# 或者: from Login import login [as 别名]
#!/usr/bin/env python
# ----------------
# ShowDatabases.py
# ----------------
import Login
import Query
print("ShowDatabases.py")
c = Login.login()
assert(str(type(c)) == "<type '_mysql.connection'>")
t = Query.query(c, "show databases")
assert(type(t) is tuple)
assert(t == \
(('information_schema',), \
('downing',), \
('downing_cs327e',), \
('downing_cs370',), \
('downing_cs371p',), \
('downing_cs373',), \
('downing_cs378',), \
('downing_dml',), \
('downing_test',), \
('drupal_dml',)))
print("Done.")
示例8: reload
# 需要导入模块: import Login [as 别名]
# 或者: from Login import login [as 别名]
# -*- coding: utf-8 -*-
import WeiboLogin
import Login
import urllib2
import re
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
#调用模拟登录的程序,从网页中抓取指定URL的数据,获取原始的HTML信息存入raw_html.txt中
def get_rawHTML(url):
#Login.login()
content = urllib2.urlopen(url).read()
fp_raw = open("f://emotion/mysite/weibo_crawler/raw_html.txt","w+")
fp_raw.write(content)
fp_raw.close() #获取原始的HTML写入文件
#print "成功爬取指定网页源文件并且存入raw_html.txt"
return content #返回值为原始的HTML文件内容
if __name__ == '__main__':
Login.login() #先调用登录函数
#url = 'http://weibo.com/yaochen?is_search=0&visible=0&is_tag=0&profile_ftype=1&page=1#feedtop' #姚晨
url = 'http://weibo.com/fbb0916?is_search=0&visible=0&is_tag=0&profile_ftype=1&page=1#feedtop' #自行设定要抓取的网页
get_rawHTML(url)
示例9: open
# 需要导入模块: import Login [as 别名]
# 或者: from Login import login [as 别名]
#fp2 = open("chinese_weibo.txt","a") #初始化写入文件
for readline in read:
utf8_readline = unicode(readline,'utf-8')
if pattern.search(utf8_readline): #如果在该句话中能找到中文文本则进行处理
#print readline #测试
split_readline = readline.split(' ') #由空格对文本进行分割,split_readline是一个list
for c in split_readline:
c = re.sub(r'发布者:[.]*','',c) #去掉“发布者”
c = re.sub(r'百度[.]*','',c) #去掉“百度”
c = re.sub(r'正在加载中[.]*','',c)
c = re.sub(r'360安全浏览[.]*','',c)
c = re.sub(r'抱歉[.]*','',c)
c = re.sub(r'.*?高速浏览.*','',c)
#print c,len(c)
if len(c) > 16: #提出过短的文本,utf-8编码中一个中文为3个字节长度
fp2.write(c)
#print "c",c
fp1.close()
#fp2.close() #文件关闭
#print "成功解析网页提取微博并且存入chinese_weibo.txt"
if __name__ == '__main__':
#自行设定要抓取的网页,抓取范冰冰微博的1到5页
Login.login()
for i in range(4):
i = i + 1
url = 'http://weibo.com/yaochen?is_search=0&visible=0&is_tag=0&profile_ftype=1&page=' + str(i) + '#feedtop'
#url = 'http://weibo.com/fbb0916?is_search=0&visible=0&is_tag=0&profile_ftype=1&page=' + str(i) + '#feedtop'
content = get_rawHTML(url)
Handel(content) #测试,调用该函数执行
示例10: testAddProdect
# 需要导入模块: import Login [as 别名]
# 或者: from Login import login [as 别名]
def testAddProdect(self):
br=Login.login(self.driver,self.baseurl)
log=ResultLog.resultLog()
br.maximize_window()
time.sleep(5)
# m="我的会员中心".decode("utf-8")
#br.find_element_by_xpath("//div[@class='mod-login']/div[3]/div[2]/a[contains(text(),m)]").click()
#br.find_element_by_link_text(u"我的会员中心").click()
br.find_element_by_css_selector("a.red").click()
time.sleep(5)
br.switch_to_window(br.window_handles[1])
br.find_element_by_link_text(u"我是供应商").click()
time.sleep(3)
br.find_element_by_link_text(u"产品管理").click()
br.find_element_by_link_text(u"发布信息").click()
br.find_element_by_id("userItem").click()#网站栏目选择
br.find_element_by_link_text(u"供应信息").click()
br.find_element_by_css_selector("button.btn.selectOk").click()
br.find_element_by_id("newsItem").click()#产品类别选择
time.sleep(5)
br.find_element_by_css_selector("a[Data-id='1000001008']").click()
time.sleep(2)
br.find_element_by_css_selector("a[Data-id='1000001008001']").click()
time.sleep(2)
br.find_element_by_css_selector("a[Data-id='1000001008001001']").click()
time.sleep(2)
br.find_element_by_xpath("//*[@id='seeNewsItemsBody']/div[3]/button").click()#产品类别选择对话框的确定按钮
br.find_element_by_id("infoTitle").send_keys(self.tit.decode("utf-8"))#产品标题
br.find_element_by_id("infoFlag").send_keys("wwg")#关键词
br.find_element_by_id("proBrandName").find_element_by_css_selector("option[value=\"生鸡蛋\"]").click()#品牌名称
br.find_element_by_id("proStandard").send_keys("wwg")#规格
br.find_element_by_id("proCompany").send_keys("wwg")#生产厂家
js1="$(\"input[Data-provide='datetimepicker' ]\").removeAttr('readonly');$(\"input[Data-provide='datetimepicker']\").attr('value','2014-08-09')"
br.execute_script(js1)#生产日期
br.find_element_by_id("infoPrice").send_keys("1")#批发价
br.find_element_by_id("pricelast").send_keys("1")#零售价
br.find_element_by_id("infoCon").send_keys("2222")#供应量
br.find_element_by_id("proMinNum").send_keys("1")#最小起订量
br.find_element_by_id("province").find_element_by_css_selector("option[value=\"10008\"]").click()
br.find_element_by_id("city").find_element_by_css_selector("option[value=\"10009\"]").click()#发货地
br.find_element_by_id("proDaysLimit").send_keys("1")#发货期限
br.find_element_by_xpath("//*[@id='img_list']/p[1]/a/img").click()
time.sleep(3)
br.find_element_by_xpath("//*[@id='tabNavi']/ul/li[2]").click()
br.find_element_by_id("imgFile").send_keys("E:\\wwg\\xampp\\php\\php.gif")
time.sleep(2)
br.find_element_by_id("upToServer").click()#图片
br.find_element_by_id("infoBrief").send_keys("wwg")#产品简介
content="wwg"
#js2="document.getElementsByClassName(\"ke-iframe\")[0].contentWindow.document.body.innerHTML=\"%s\" " %(u"是打发士大夫士大夫是地方")
js2="KE.text('infoContent','123wwg')"
br.execute_script(js2)#产品详情
js3="document.getElementsByClassName(\"ke-iframe\")[1].contentWindow.document.body.innerHTML=\"%s\"" %(content)
br.execute_script(js3)#配送说明
time.sleep(10)
br.find_element_by_id("saveBtn").click()
time.sleep(8)
br.find_element_by_link_text(u"身份认证").click()
br.find_element_by_link_text(u"产品管理").click()
br.find_element_by_link_text(u"信息管理").click()
time.sleep(5)
#调用数据库查询验证产品发布是否成功
oracle.ora(self.tit.decode("utf-8").encode("gbk"))
#通过页面元素判断产品发布是否成功
try:
product=br.find_element_by_link_text("safdfsdfsdfsdfsdfdsf").is_displayed()
if product:
log.info("通过界面验证产品:%s发布成功" %self.tit)
else:
log.info("通过界面验证产品:%s没有发布成功" %self.tit)
except:
log.info("没有找到此元素")
示例11: str
# 需要导入模块: import Login [as 别名]
# 或者: from Login import login [as 别名]
mt = urllib2.urlopen( url )
s = mt.read()
c = str(s)
if ct == 1:
fout = open('pincode.html', 'w')
fout.write( c )
fout.close()
ct = 0
getInformation( c )
dealwithdata()
print "success"
if __name__ == '__main__':
users = [ '[email protected]', '15889962394', '15902055133' ]
pwds = [ 'crawler123456', '19910912', 'crawler123456' ]
'''以上为申请的三个用于爬取数据的微博账号,可交替登陆'''
l = len(users)
num = random.randint(0, l-1)
username = users[num]
pwd = pwds[num]
#如果登录成功就爬取数据
if Login.login( username, pwd ):
main()
示例12: print
# 需要导入模块: import Login [as 别名]
# 或者: from Login import login [as 别名]
import Login
import Info
import requests
import http
import re
import time
import os
if __name__ == '__main__':
if Login.isLogin():
print("已登录")
else:
account = input("请输入你的用户名\n> ")
secret = input("请输入你的密码\n> ")
Login.login(secret, account)
index_page = Login.session.get('https://www.zhihu.com/#signin', headers=Login.headers) #主页
#index_page = Login.session.get('https://www.zhihu.com/explore', headers=Login.headers) #发现
"""
f = open('C:\\Users\\penguin\\Desktop\\dump.txt', 'wb+')
f.write(index_page.content)
f.close()
file = open('C:\\Users\\penguin\\Desktop\\dump.txt', 'r+', encoding= 'utf-8')
"""
file_name = str(time.localtime()[0]) + '.' + str(time.localtime()[1]) + '.' + str(time.localtime()[2])\
+ '.' + str(time.localtime()[3]) + '.' + str(time.localtime()[4]) + '.' + str(time.localtime()[5])
file_name += '_result.txt'
path = os.getcwd() + '\\' + file_name
file = open(path, 'w+', encoding='utf-8')
p = re.compile(r'<h2 class=".*"><a class=".*" target=".*" href=".*">.*</a></h2>')
for link in p.findall(index_page.text):
示例13: CartRun
# 需要导入模块: import Login [as 别名]
# 或者: from Login import login [as 别名]
def CartRun(self,ctx):
self.urlOpener,self.cookies = Login.login(ctx,self.user,self.password,self.login_url)
req = self.urlOpener.open(self.cart_url)
self.cart_result = Login.convertStrToDict(req.read())
示例14: setUp
# 需要导入模块: import Login [as 别名]
# 或者: from Login import login [as 别名]
def setUp(self):
Login.login(self)
示例15: getHTML
# 需要导入模块: import Login [as 别名]
# 或者: from Login import login [as 别名]
def getHTML(url):
Login.login()
html = urllib2.urlopen(url).read()
return html