2014-12-04 3 views
-1

내 머리를 감싸는 중 ... 10 만 개의 URL로 고정되어있는 목록을 가지고 있습니다. 괜찮 았는데, 어떻게 처리해야하는지 알고 있습니다. 하지만 먼저 초기 양식 게시물에서 쿠키를 가져와 후속 요청에 사용해야합니다. 그것은 중첩 된 거미와 같을까요? 그 유스 케이스에 대한 아키텍처를 이해하려고 노력한다.치료 고정 URL

감사합니다.

답변

1

치료는 자동으로 쿠키 작업을 수행합니다.

첫 번째로 양식을 작성한 다음 100,000 개의 URL 요청을 제출하기 만하면됩니다.

class MySpider(scrapy.Spider): 
    name = "myspider" 
    start_urls = (
     'https://example.com/login', #login page 
    ) 

    def __init__(self, *args, **kwargs): 
     self.url_list = [] #your url lists 
     return super(MySpider, self).__init__(*args, **kwargs) 

    def parse(self, response): 
     data = {} 

     return scrapy.FormRequest.from_response(
      response, 
      formdata=data, 
      callback=self.my_start_requests 
     ) 

    def my_start_requests(self, response): 
     # ignore the login callback response 
     for url in self.url_list: 
      # scrapy will take care the cookies 
      yield scrapy.Request(url, callback=self.parse_item, dont_filter=True) 

    def parse_item(self, response): 
     # your code here 
     pass 
+0

절대적으로 뛰어납니다. 대단히 감사합니다! 구문에 대해서는 코드를 약간 편집해야하지만 그 자리는 수정해야합니다. –