Python scrapy - Login Authenication Issue
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的更多相关文章
- python scrapy版 极客学院爬虫V2
python scrapy版 极客学院爬虫V2 1 基本技术 使用scrapy 2 这个爬虫的难点是 Request中的headers和cookies 尝试过好多次才成功(模拟登录),否则只能抓免费课 ...
- python Scrapy安装和介绍
python Scrapy安装和介绍 Windows7下安装1.执行easy_install Scrapy Centos6.5下安装 1.库文件安装yum install libxslt-devel ...
- Python.Scrapy.14-scrapy-source-code-analysis-part-4
Scrapy 源代码分析系列-4 scrapy.commands 子包 子包scrapy.commands定义了在命令scrapy中使用的子命令(subcommand): bench, check, ...
- Python.Scrapy.11-scrapy-source-code-analysis-part-1
Scrapy 源代码分析系列-1 spider, spidermanager, crawler, cmdline, command 分析的源代码版本是0.24.6, url: https://gith ...
- python scrapy cannot import name xmlrpc_client的解决方案,解决办法
安装scrapy的时候遇到如下错误的解决办法: "python scrapy cannot import name xmlrpc_client" 先执行 sudo pip unin ...
- 教程+资源,python scrapy实战爬取知乎最性感妹子的爆照合集(12G)!
一.出发点: 之前在知乎看到一位大牛(二胖)写的一篇文章:python爬取知乎最受欢迎的妹子(大概题目是这个,具体记不清了),但是这位二胖哥没有给出源码,而我也没用过python,正好顺便学一学,所以 ...
- 天气提醒邮件服务器(python + scrapy + yagmail)
天气提醒邮件服务器(python + scrapy + yagmail) 项目地址: https://gitee.com/jerry323/weatherReporter 前段时间因为xxx上班有时候 ...
- Python -- Scrapy 框架简单介绍(Scrapy 安装及项目创建)
Python -- Scrapy 框架简单介绍 最近在学习python 爬虫,先后了解学习urllib.urllib2.requests等,后来发现爬虫也有很多框架,而推荐学习最多就是Scrapy框架 ...
- python scrapy,beautifulsoup,regex,sgmparser,request,connection
In [2]: import requests In [3]: s = requests.Session() In [4]: s.headers 如果你是爬虫相关的业务?抓取的网站还各种各样, ...
随机推荐
- LeetCode 709 To Lower Case 解题报告
题目要求 Implement function ToLowerCase() that has a string parameter str, and returns the same string i ...
- Excel--数据对比方法
1.函数对比: 适用于两列数据对比 =IF(EXACT(A2,B2)=TRUE,"相同","不同") 2.快捷键对比: 适用于少数数据对比 选中对比两列数据,快 ...
- python 去除微软的BOM
傻逼微软会给文件前面加上efbbbf, 导致开发人员浪费很多时间在排错上,下面通过python代码来实现去除微软BOM的功能 用法很简单,指定可能含有BOM开头的文件,并且将微软的\r\n 换成lin ...
- Springmvc 使用 AbstractExcelView 导出excel
$("#exportBtn").click(function () { location.href = "${pageContext.request.contextPat ...
- 异步fifo的Verilog实现
一.分析 由于是异步FIFO的设计,读写时钟不一样,在产生读空信号和写满信号时,会涉及到跨时钟域的问题,如何解决? 跨时钟域的问题:由于读指针是属于读时钟域的,写指针是属于写时钟域的,而异步FIFO ...
- aws小结
IAM:亚马逊访问权限控制(AWS Identity and Access Management ) https://www.cnblogs.com/andy9468/p/10635019.html ...
- 并发编程---Process对象的其他属性或方法
Process对象的其他属性或方法 #join方法 from multiprocessing import Process import time,os ''' 需求:让主进程等着子进程运行完毕,才能 ...
- 004-restful应用构建、分布式会话、测试工具简介
一.概述 什么是rest(表述性状态转移,Representational State Transfer)是一种架构风格.他定义了创建可扩展Web服务的最佳实践. 1.Richardson成熟度模型 ...
- PHP 生成器入门
https://juejin.im/entry/5b4c2d76f265da0f697029ad PHP 在 5.5 版本中引入了「生成器(Generator)」特性,不过这个特性并没有引起人们的注意 ...
- 微信小程序github源码
https://github.com/justjavac/awesome-wechat-weapp https://www.cnblogs.com/tuyile006/p/6268961.html h ...