def parse(self, response):
# pattern1 = re.compile('token=(.*?);')
# token = pattern1.findall(response.headers.getlist("set-cookie")[1].decode("utf-8"))[0] pattern2 = re.compile('token=(.*?);')
token = pattern2.findall(response.headers.getlist("set-cookie")[1].decode("utf-8"))[0]
token_md5= token.encode("utf-8")
sign= hashlib.md5(token_md5).hexdigest()
cookie = {
'token': token,
}
url='https://scrapingclub.com/exercise/ajaxdetail_sign/?sign='+sign
yield scrapy.Request(url= url,cookies=cookie,headers=header,callback=self.parse_json)

关键在于把token转成MD5

def get_md(url):
m = hashlib.md5()
m.update(url)
return m.hexdigest()
copy from: https://www.jianshu.com/p/271b20f7574f

用到了其中的两句,不知道为什么要update,其中就像原作者说的,不能直接hashlib.md5(str)必须是byte,需要转码一次

https://scrapingclub.com/exercise/detail_sign/的更多相关文章

  1. https://scrapingclub.com/exercise/basic_captcha/

    def parse(self, response): # set_cookies = response.headers.getlist("set-cookie").decode(& ...

  2. https://scrapingclub.com/exercise/basic_login/

    遇到的问题:csrftoken cfduid 是在request.headers里面的,一直在找怎么在scrapy里get request.header,从scrapy shell ,then fet ...

  3. https://scrapingclub.com/exercise/detail_cookie/

    def parse(self, response): pattern=re.compile('token=(.*?);') token=pattern.findall( response.header ...

  4. materials

    http://interactivepython.org/runestone/static/pythonds/index.html https://blog.michaelyin.info/scrap ...

  5. Pycharm学习python路

    import 模块之后是灰色的表明没有被引用过 lxml找不到的话用anaconda prompt :pip uninstall lxml 重新安装 用request时,写的reg无法正确解析网页,先 ...

  6. MIT 6.828 JOS学习笔记5. Exercise 1.3

    Lab 1 Exercise 3 设置一个断点在地址0x7c00处,这是boot sector被加载的位置.然后让程序继续运行直到这个断点.跟踪/boot/boot.S文件的每一条指令,同时使用boo ...

  7. MIT 6.828 JOS学习笔记3. Exercise 1.2

    这篇博文是对Lab 1中的Exercise 2的解答~ Lab 1 Exercise 2: 使用GDB的'si'命令,去追踪ROM BIOS几条指令,并且试图去猜测,它是在做什么.但是不需要把每个细节 ...

  8. (14)Why some people find exercise harder than others

    https://www.ted.com/talks/emily_balcetis_why_some_people_find_exercise_harder_than_others/transcript ...

  9. 【原】Coursera—Andrew Ng机器学习—编程作业 Programming Exercise 4—反向传播神经网络

    课程笔记 Coursera—Andrew Ng机器学习—课程笔记 Lecture 9_Neural Networks learning 作业说明 Exercise 4,Week 5,实现反向传播 ba ...

随机推荐

  1. Nginx+Keepalived+Tomcat高可用负载均衡,Zookeeper集群配置,Mysql(MariaDB)搭建,Redis安装,FTP配置

    JDK 安装步骤 下载 http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html rpm ...

  2. 同步调用异步方法how-would-i-run-an-async-taskt-method-synchronously

    同步调用异步方法帮助类: public static class AsyncHelpers { /// <summary> /// Execute's an async Task<T ...

  3. pyCharm最新激活码(2018激活码)

    首先输入新的License sever address 首先尝试处理方法是,针对过期会弹出激活框: 选择 Activate new license with License server (用lice ...

  4. CentOS安装和配置Nginx

    1. 首先Nginx官网找到最新的稳定版本,网站地址:http://nginx.org/en/linux_packages.html#stable 在/etc/yum.repos.d 下面创建一个文件 ...

  5. 转:The Difference Between a LayoutTransform and a RenderTransform

    来自:http://www.tuicool.com/articles/fIfm22 #770 – The Difference Between a LayoutTransform and a Rend ...

  6. Redis介绍和安装

    一. Redis的介绍 Redis 是一个Key-Value存储的系统:它支持存储的value类型有string(字符串),list(列表),set(集合),zset(有序集合):为了保证效率:数据都 ...

  7. react withClamp装饰器

    Clamp.js 等待异步数据加载完后在初始化$clamp withClamp.js import React, { Component } from "react"; expor ...

  8. linux的基本操作(shell 脚本的基础知识)

    shell 脚本的基础知识 日常的linux系统管理工作中必不可少的就是shell脚本,如果不会写shell脚本,那么你就不算一个合格的管理员.目前很多单位在招聘linux系统管理员时,shell脚本 ...

  9. 七牛免费SSL证书申请全流程

    购买证书 在七牛ssl 首页点击购买 购买限免证书 补全订单信息 免费证书,随意填写,问题不大 购买成功,查看订单详情,获取 TXT 值信息 添加 DNS TXT 验证 根据上一步,查看证书订单详情, ...

  10. python中文分词库——pyltp

    pyltp在win10下安装比较麻烦,因此参考以下安装方式, 1.下载 win10下python3.6 2.安装 下载好了以后, 在命令行下, cd到wheel文件所在的目录, 然后使用命令pip i ...