本文整理汇总了Python中post.Post.logon方法的典型用法代码示例。如果您正苦于以下问题:Python Post.logon方法的具体用法?Python Post.logon怎么用?Python Post.logon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类post.Post
的用法示例。
在下文中一共展示了Post.logon方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Parsesites
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import logon [as 别名]
#-*-coding:utf-8 -*-
from post import Post
from parsers import Parse
from config import USERNAME
from parse_sites import Parsesites
if __name__ == "__main__":
Parsesites()
items = Parse().items
p = Post()
login_response = p.logon().content.decode("utf-8")
# if not valid login, exit
if "我的录入" not in login_response:
print("login failed")
exit()
# total = len(items)
# count = 2976
for item in items:
# print(count, "/", total)
print(USERNAME, "posting", item['websiteplate'], item['url'])
r = p.post(item)
print(r.content.decode("utf-8"))
# count += 1
示例2: get_avg_download_times
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import logon [as 别名]
USERID = 28
ROWS = 1700
def get_avg_download_times(info_id, p):
r = p.session.get(INFO_DETAILS, params={'id': info_id})
html = r.content.decode('utf-8')
value_list_line = [x for x in html.split('\n') if 'var valueList =' in x][0]
lst = re.sub(r'var valueList =|[\r\t;]', r'', value_list_line)
valueList = eval(lst) # valueList = [.., ..]
# get average download times
avg = sum(valueList) / len(valueList)
return avg
if __name__ == "__main__":
p = Post()
p.logon()
items = p.session.post(LIST,{'userid':USERID,'rows':ROWS})
res = items.content.decode('utf-8')
infos = eval(res)['infos']
count = 0
total = len(infos)
f = open('statistics','a')
for info in infos:
print(count, '/', total)
id = info['id']