Scrappy가있는 사이트에 로그인하고 다른 URL을 호출하고 싶습니다. 지금까지 너무 좋아 내가 공세를 설치하고이 스크립트를 만든 :이 스크립트를 실행 한 후Scrappy로 쿠키를 연결하고 저장하는 방법
from scrapy.spider import BaseSpider
from scrapy.selector import HtmlXPathSelector
from scrapy.http import FormRequest
class LoginSpider2(BaseSpider):
name = 'github_login'
start_urls = ['https://github.com/login']
def parse(self, response):
return [FormRequest.from_response(response, formdata={'login': 'username', 'password': 'password'}, callback=self.after_login)]
def after_login(self, response):
if "authentication failed" in response.body:
self.log("Login failed", level=log.ERROR)
else:
self.log("Login succeed", response.body)
을, 나는 로그가 "로그인 성공"있어요. 는 그럼 난 다른 URL을 추가했지만 작동하지 않았다 : 을 위해 내가 대체하는 것이 :
start_urls = ['https://github.com/login']
start_urls = ['https://github.com/login', 'https://github.com/MyCompany/MyPrivateRepo']
에 의해 그러나 나는 이러한 오류 가지고 :
2013-06-11 22:23:40+0200 [scrapy] DEBUG: Enabled item pipelines:
Traceback (most recent call last):
File "/usr/local/bin/scrapy", line 4, in <module>
execute()
File "/Library/Python/2.7/site-packages/scrapy/cmdline.py", line 131, in execute
_run_print_help(parser, _run_command, cmd, args, opts)
File "/Library/Python/2.7/site-packages/scrapy/cmdline.py", line 76, in _run_print_help
func(*a, **kw)
File "/Library/Python/2.7/site-packages/scrapy/cmdline.py", line 138, in _run_command
cmd.run(args, opts)
File "/Library/Python/2.7/site-packages/scrapy/commands/crawl.py", line 43, in run
spider = self.crawler.spiders.create(spname, **opts.spargs)
File "/Library/Python/2.7/site-packages/scrapy/spidermanager.py", line 43, in create
raise KeyError("Spider not found: %s" % spider_name)
를 내가 잘못하고있는거야? I에 유래에 검색하지만 적절한 응답을 찾지 못했습니다 ..
감사합니다 당신이