ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
``` # -*- 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) ```