def parse(self, response):

        pattern=re.compile('token=(.*?);')
token=pattern.findall( response.headers.get("set-cookie").decode("utf-8"))[0]
cookie = {
'__cfduid': 'd67f5270ed84c0000af9c771fdee950631551004073',
'_ga': 'GA1.2.2009295084.1551004056',
'_gid': 'GA1.2.513859849.1551004056',
'token': token
}
yield scrapy.Request(url='https://scrapingclub.com/exercise/ajaxdetail_cookie/?token='+str(token),cookies=cookie,headers=header,callback=self.parse_json)

settings.py

COOKIES_ENABLED = True
DEFAULT_REQUEST_HEADERS = {
# 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
# 'Accept-Language': 'en',
# 'cookie': '__cfduid=d67f5270ed84c0000af9c771fdee950631551004073; _ga=GA1.2.2009295084.1551004056; _gid=GA1.2.513859849.1551004056; token=685NVSGV2O',
# 'dnt': '1',
'referer': 'https://scrapingclub.com/exercise/detail_cookie/',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36',
'x-requested-with': 'XMLHttpRequest'
}

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

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

    def parse(self, response): # pattern1 = re.compile('token=(.*?);') # token = pattern1.findall(respon ...

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

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

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

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

  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. eclipse怎么解决Failed to load the JNIshared library

    Q: 打开eclipse打开报Failed to load the JNIshared library的错误. A:jdk的位数跟eclipse位数一致即可解决. 把eclipse下载64位即可 cm ...

  2. 对于python setup install的程序如何删除干净

    python很好用,尤其是用过easy_install的朋友更是觉得它的便捷,卸载命令也很简单 easy_install -m package-name但是面对源码安装的怎么办呢? setup.py ...

  3. monitor

    // ==UserScript== // @name Page Monitor // @namespace http://tampermonkey.net/ // @version 0.1 // @d ...

  4. linux常用文件

    /etc/redhat-release /etc/hostname /etc/ssh/sshd_config /proc/meminfo /etc/issue 查看系统版本号 /etc/rc.d/rc ...

  5. Redis和Memcache的区别是什么

    Redis和Memcache都是内存数据库,但它们之间还是有区别的,跟着ytkah看看Redis和Memcache的区别吧 Redis 支持多种数据结构,如string,list,dict,set,z ...

  6. Python3学习之路~2.7 文件操作

    对文件操作流程 打开文件,得到文件句柄并赋值给一个变量 通过句柄对文件进行操作 关闭文件 现有文件如下 Somehow, it seems the love I knew was always the ...

  7. test TSS Work about

     activity01   activity02   FamilyNew   workTest

  8. vux 是基于 WeUI 和Vue(2.x)开发的移动端UI组件库,主要服务于微信页面。

    https://doc.vux.li/zh-CN/ https://vux.li/

  9. pro*c的使用

    一.什么是Pro*c程序 在oracle数据库管理系统中,有三种访问数据库的方法:       1.用 SQL*Plus,直接输入sql命令以命令行交换的方式访问数据库       2.用一些应用开发 ...

  10. Lua获取当前时间

    更多好的文章就在 blog.haoitsoft.com,请大家多多支持! local getTime = os.date(“%c”); 其中的%c可以是以下的一种:(注意大小写) %a abbrevi ...