本文整理汇总了Python中src.tools.http.Http.set_cookie方法的典型用法代码示例。如果您正苦于以下问题:Python Http.set_cookie方法的具体用法?Python Http.set_cookie怎么用?Python Http.set_cookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类src.tools.http.Http
的用法示例。
在下文中一共展示了Http.set_cookie方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_config
# 需要导入模块: from src.tools.http import Http [as 别名]
# 或者: from src.tools.http.Http import set_cookie [as 别名]
def init_config(recipe_kind):
if recipe_kind == 'zhihu': # TODO: 再有一个需要登录的网站, 改掉硬编码
login = Login(recipe_kind='zhihu')
else:
return
# !!!!!发布的时候把Config.remember_account改成false!!!!!,第一次需要登录,之后用cookie即可
# 登陆成功了,自动记录账户
if Config.remember_account_set:
Debug.logger.info(u'检测到有设置文件,直接使用之前的设置')
# if raw_input():
# login.start()
# Config.picture_quality = guide.set_picture_quality()
Config.picture_quality = 1
# else:
try:
Http.set_cookie() # sinablog, jianshu: DontNeed
except TypeError:
print u"没有找到登录成功的cookie记录, 请重新登录"
login.start()
else:
log.warning_log(u"Please login...")
login.start()
# Config.picture_quality = guide.set_picture_quality()
Config.picture_quality = 1
Config.remember_account_set = True
# save config
Config._save()
return
示例2: __init__
# 需要导入模块: from src.tools.http import Http [as 别名]
# 或者: from src.tools.http.Http import set_cookie [as 别名]
def __init__(self, task_list):
self.task_set = set(task_list)
self.work_set = set() # 待抓取网址池
self.answer_list = []
self.question_list = []
self.thread_pool = ThreadPool(Config.max_thread)
self.info_list = []
self.extra_index_list = []
self.info_url_set = self.task_set.copy()
self.add_property() # 添加扩展属性
Http.set_cookie()
示例3: __init__
# 需要导入模块: from src.tools.http import Http [as 别名]
# 或者: from src.tools.http.Http import set_cookie [as 别名]
def __init__(self, task_list):
self.task_set = set(task_list)
self.task_complete_set = set()
self.work_set = set() # 待抓取网址池
self.work_complete_set = set() # 已完成网址池
self.content_list = [] # 用于存放已抓取的内容
self.answer_list = []
self.question_list = []
self.info_list = []
self.extra_index_list = []
self.info_url_set = self.task_set.copy()
self.info_url_complete_set = set()
self.add_property() # 添加扩展属性
Http.set_cookie()
示例4: init_config
# 需要导入模块: from src.tools.http import Http [as 别名]
# 或者: from src.tools.http.Http import set_cookie [as 别名]
def init_config():
login = Login()
if Config.remember_account:
print u"检测到有设置文件,是否直接使用之前的设置?(帐号、密码、图片质量)"
print u"点按回车使用之前设置,敲入任意字符后点按回车进行重新设置"
if raw_input():
login.start()
Config.picture_quality = guide.set_picture_quality()
else:
Http.set_cookie()
else:
login.start()
Config.picture_quality = guide.set_picture_quality()
# 储存设置
Config._save()
return
示例5: __init__
# 需要导入模块: from src.tools.http import Http [as 别名]
# 或者: from src.tools.http.Http import set_cookie [as 别名]
def __init__(self, task_list):
self.task_set = set(task_list)
self.task_complete_set = set()
self.work_set = set() # 待抓取网址池
self.work_complete_set = set() # 已完成网址池
self.content_list = [] # 用于存放已抓取的内容
self.answer_list = []
self.question_list = []
self.info_list = []
self.extra_index_list = []
self.info_url_set = self.task_set.copy()
self.info_url_complete_set = set()
# 添加扩展属性
self.add_property()
Config._load() # TODO: 可能对性能有影响,改成运行时的环境变量?
if Config.need_account:
Debug.logger.debug("Need cookie")
Http.set_cookie()
else:
Debug.logger.debug("Don't need cookie")
Http.set_cookie('DontNeed')