|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
运行报错。
报错的信息:- 2018-12-24 15:44:42 [scrapy.core.scraper] ERROR: Spider error processing <GET http://poxiao.com/movie/10002.html via http://localhost:8050/render.html> (referer: None)
- Traceback (most recent call last):
- File "e:\python\lib\site-packages\twisted\internet\defer.py", line 654, in _runCallbacks
- current.result = callback(current.result, *args, **kw)
- File "E:\movie\movie\spiders\poxiao.py", line 30, in parse
- iss = FormRequest.from_response('http://192.168.83.81/1/1.html',formdata=self.fd,callback=self.movie_save)
- File "e:\python\lib\site-packages\scrapy\http\request\form.py", line 42, in from_response
- kwargs.setdefault('encoding', response.encoding)
- AttributeError: 'str' object has no attribute 'encoding'
复制代码
运行的代码:
- # -*- coding: utf-8 -*-
- import scrapy
- from scrapy_splash import SplashRequest
- import time
- from scrapy.http import FormRequest,Request
- class PoxiaoSpider(scrapy.Spider):
- name = 'poxiao'
- start_urls = ['http://poxiao.com/']
- fd = {}
- def start_requests(self):
- for number in range(10000,10005):
- for start_url in self.start_urls:
- url = str(start_url)+'movie/'+str(number)+'.html'
- time.sleep(1)
- yield SplashRequest(url,args={'images':0,'timeout':3})
- def parse(self, response):
- name = (response.css('div#film h1::text').extract_first())
- down = []
- for downlink in response.css('div.resourcesmain tr'):
- downl = downlink.css('td.sebc3 a::attr(href)').extract_first()
- down.append(downl)
- if down.count(None):down.pop()
- self.fd = {'wz':response.url,
- 'bt':name,
- 'picture':'None',
- 'xzll':down,}
- ## yield Request('http://192.168.83.81/1/1.html')
- yield FormRequest.from_response('http://192.168.83.81/1/1.html',formdata=self.fd,callback=self.movie_save)
- def movie_save(self,response):
- yield from super().start_requests()
- ## yield{'url':response.url,
- ## 'name':name,
- ## 'down':down,}
复制代码 |
|