鱼C论坛

 找回密码
 立即注册
查看: 981|回复: 1

Scrapy的错误。

[复制链接]
发表于 2018-12-24 15:47:57 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
运行报错。
报错的信息:
  1. 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)
  2. Traceback (most recent call last):
  3.   File "e:\python\lib\site-packages\twisted\internet\defer.py", line 654, in _runCallbacks
  4.     current.result = callback(current.result, *args, **kw)
  5.   File "E:\movie\movie\spiders\poxiao.py", line 30, in parse
  6.     iss = FormRequest.from_response('http://192.168.83.81/1/1.html',formdata=self.fd,callback=self.movie_save)
  7.   File "e:\python\lib\site-packages\scrapy\http\request\form.py", line 42, in from_response
  8.     kwargs.setdefault('encoding', response.encoding)
  9. AttributeError: 'str' object has no attribute 'encoding'
复制代码


运行的代码:
  1. # -*- coding: utf-8 -*-
  2. import scrapy
  3. from scrapy_splash import SplashRequest
  4. import time
  5. from scrapy.http import FormRequest,Request
  6. class PoxiaoSpider(scrapy.Spider):
  7.     name = 'poxiao'
  8.     start_urls = ['http://poxiao.com/']
  9.     fd = {}

  10.     def start_requests(self):
  11.         for number in range(10000,10005):
  12.             for start_url in self.start_urls:
  13.                 url = str(start_url)+'movie/'+str(number)+'.html'
  14.                 time.sleep(1)
  15.                 yield SplashRequest(url,args={'images':0,'timeout':3})

  16.     def parse(self, response):
  17.         name = (response.css('div#film h1::text').extract_first())
  18.         down = []
  19.         for downlink in response.css('div.resourcesmain tr'):
  20.             downl = downlink.css('td.sebc3 a::attr(href)').extract_first()
  21.             down.append(downl)
  22.         if down.count(None):down.pop()
  23.         self.fd = {'wz':response.url,
  24.                   'bt':name,
  25.                   'picture':'None',
  26.                   'xzll':down,}
  27. ##        yield Request('http://192.168.83.81/1/1.html')
  28.         yield FormRequest.from_response('http://192.168.83.81/1/1.html',formdata=self.fd,callback=self.movie_save)
  29.     def movie_save(self,response):
  30.         yield from super().start_requests()
  31. ##            yield{'url':response.url,
  32. ##                  'name':name,
  33. ##                  'down':down,}
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2018-12-24 16:21:42 | 显示全部楼层
你爬取url=https://www.poxiao.com/ 能把项目需求写一下吗?
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2026-1-12 14:33

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表