NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
``` # -*- coding: utf-8 -*- import scrapy class RenrenSpider(scrapy.Spider): name = 'renren' allowed_domains = ['renren.com'] start_urls = ['http://www.renren.com/PLogin.do'] # 实现post请求,重写start_requests方法,因为Spider类中默认实现的Request请求,请求方法为GET def start_requests(self): url = self.start_urls[0] post_data = { 'email': '18949599846', 'password':'shengjun' } yield scrapy.FormRequest(url, method='POST', formdata=post_data, callback=self.parse) def parse(self, response): with open("renren.html", "wb") as f: f.write(response.body) ```