2018/8/28更新,填坑完毕,改用selenium
先挖一个坑,过一阵再填坑
def check_login(self, response): ''' cookie_jar.extract_cookies(response, response.request) with open('cookies.txt', 'w') as f: for cookie in cookie_jar: f.write(str(cookie) + '\n') f.close() with open('cookies.txt', 'r') as f: cookie_save_file = f.read() p = re.compile('\') cookies = re.findall(p, cookie_save_file) cookies = (cookie.split('=', 1) for cookie in cookies) cookies = dict(cookies) f.close() yield scrapy.Request('https://www.zhihu.com', headers=self.headers, cookies=cookies) '''