https://stackoverflow.com/questions/37841409/python-scrapy-login-authenication-issue

from scrapy.crawler import CrawlerProcess
import scrapy from scrapy.http import Request class FirstSpider(scrapy.Spider):
name = "first"
allowed_domains = ["instacart.com"]
start_urls = [
"https://www.instacart.com"
] def start_requests(self):
return [Request(url="https://www.instacart.com", callback=self.login)] def login(self, response):
return scrapy.FormRequest('https://www.instacart.com/accounts/login',
headers={"X-Requested-With": "XMLHttpRequest"},
formdata={'user[email]': 'xxxxxxx@gmail.com', 'user[password]': 'xxxxx',
"authenticity_token": response.xpath(
"//meta[@name='csrf-token']/@content").extract_first()},
callback=self.parse,dont_filter=True) def parse(self, response):
print(response.body)
if "Goutam" in response.body:
print "Successfully logged in. Let's start crawling!"
else:
print "Login unsuccessful"

Python scrapy - Login Authenication Issue的更多相关文章

  1. python scrapy版 极客学院爬虫V2

    python scrapy版 极客学院爬虫V2 1 基本技术 使用scrapy 2 这个爬虫的难点是 Request中的headers和cookies 尝试过好多次才成功(模拟登录),否则只能抓免费课 ...

  2. python Scrapy安装和介绍

    python Scrapy安装和介绍 Windows7下安装1.执行easy_install Scrapy Centos6.5下安装 1.库文件安装yum install libxslt-devel ...

  3. Python.Scrapy.14-scrapy-source-code-analysis-part-4

    Scrapy 源代码分析系列-4 scrapy.commands 子包 子包scrapy.commands定义了在命令scrapy中使用的子命令(subcommand): bench, check, ...

  4. Python.Scrapy.11-scrapy-source-code-analysis-part-1

    Scrapy 源代码分析系列-1 spider, spidermanager, crawler, cmdline, command 分析的源代码版本是0.24.6, url: https://gith ...

  5. python scrapy cannot import name xmlrpc_client的解决方案,解决办法

    安装scrapy的时候遇到如下错误的解决办法: "python scrapy cannot import name xmlrpc_client" 先执行 sudo pip unin ...

  6. 教程+资源,python scrapy实战爬取知乎最性感妹子的爆照合集(12G)!

    一.出发点: 之前在知乎看到一位大牛(二胖)写的一篇文章:python爬取知乎最受欢迎的妹子(大概题目是这个,具体记不清了),但是这位二胖哥没有给出源码,而我也没用过python,正好顺便学一学,所以 ...

  7. 天气提醒邮件服务器(python + scrapy + yagmail)

    天气提醒邮件服务器(python + scrapy + yagmail) 项目地址: https://gitee.com/jerry323/weatherReporter 前段时间因为xxx上班有时候 ...

  8. Python -- Scrapy 框架简单介绍(Scrapy 安装及项目创建)

    Python -- Scrapy 框架简单介绍 最近在学习python 爬虫,先后了解学习urllib.urllib2.requests等,后来发现爬虫也有很多框架,而推荐学习最多就是Scrapy框架 ...

  9. python scrapy,beautifulsoup,regex,sgmparser,request,connection

    In [2]: import requests   In [3]: s = requests.Session()   In [4]: s.headers 如果你是爬虫相关的业务?抓取的网站还各种各样, ...

随机推荐

  1. Java之旅_面向对象_接口

    参考摘自:http://www.runoob.com/java/java-interfaces.html 接口(interface)在Java中是一个抽象类型,是抽象方法的集合. 一个类通过imple ...

  2. Entity Framework中IQueryable, IEnumerable, IList的区别(转载)

    原文:http://www.cnblogs.com/hiteddy/archive/2011/10/01/Difference_among_IQueryable_IEnumeralb_IList_in ...

  3. Vue 通过 Lodash 限制操作频率

    <template> <div id="watch-example"> <p> Ask a yes/no question: <input ...

  4. du 查看文件大小

    [root@localhost ~]# du -sh /etc # 查看目录下所有文件大小 [root@localhost ~]# du -sh * # 查看所有文件大小

  5. Magento 2数据库EAV模型结构

     EAV模型是一种数据模型 ,用于描述实体的数量预计会很大,但事实上,实体中要使用的属性数量并不多. Magento 2这么设计是为了灵活性,在不影响主干的基础上,任意新增删除属性. EAV模型(E ...

  6. Redis入门到高可用(六)—— 字符串

    一.结构和命令 1.字符串键值结构 key是字符串,value可以是字符串.数字.二进制.json等: redis的key和string类型value限制均为512MB. 2.使用场景 ♦️ 缓存 ♦ ...

  7. 前端框架之Vue(6)-列表渲染

    用v-for把一个数组对应为一组元素 我们用 v-for 指令根据一组数组的选项列表进行渲染. v-for 指令需要使用 item in items 形式的特殊语法, items 是源数据数组并且 i ...

  8. 为chrome设置代理

    1:打开google>setting>proxy  ,点击局域网设置. 2: 设置代理,当使用代理访问不了公司的网络时,需要将代理勾掉,将上面的公司用的网选上.

  9. Java实现个人博客网站

    说明:该项目是实验楼用户"LOU3165780622"发布在实验楼上的项目教程:[Java实现个人博客],未经允许,禁止转载: 该项目利用 SSM 框架和 Mysql 以及一些简单 ...

  10. [ErrorException] "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?

    Mac上PHP更新到7.3,使用Composer报这个错误 解决办法: composer selfupdate