-1
我是scrapy的新手,我搜索了很多,但我找不到任何可以显示如何使用scrapy登录的工作示例。Scrapy和github登录
我准备这个github上登录代码来了解流量模式,但好像它是不工作...
谁能告诉我怎样才能做到这一点?
在此先感谢。
import scrapy
from scrapy.spider import BaseSpider
from scrapy.http import FormRequest
class SpiderOne(BaseSpider):
name = "spider"
allowed_domains = ["github.com"]
start_urls = ["https://github.com/login"]
def parse(self, response):
print "in parse function"
return [FormRequest.from_response(
response,
url='https://github.com/session',
method="POST",
formdata={
'login':'valid_email',
'password':'valid_password'
},
callback=self.after_login()
)]
def after_login(self, response):
print "in after_login function"
print response
非常感谢!现在我获得状态200. – abhishake
非常感谢如果您接受此答案 – Prabhakar
完成! 如果你能告诉我,我怎样才能赶上github的下一个响应,我会非常感谢你! 我已经提出了一个请求:https://github.com/session ,我得到了这个回应的结果:https://github.com/ 此外,我是否需要设置cookie以继续爬行? – abhishake