에서 HTTP 요청을 내가 파이프 라인에서이Scrapy는, 파이프 라인
{
name: "Foo",
country: "US",
url: "http://..."
}
내가 URL에 GET 요청을하고 콘텐츠 _ 및 상태와 같은 일부 헤더를 확인하고 싶은처럼 보이는 스크랩 한 항목이 가정합니다. 헤더가 특정 조건을 충족시키지 못하면 항목을 삭제하려고합니다. 마찬가지로
class MyPipeline(object):
def process_item(self, item, spider):
request(item['url'], function(response) {
if (...) {
raise DropItem()
}
return item
}, function(error){
raise DropItem()
})
파이프 라인을 사용하여 냄새를 맡을 수 없습니다. 어떻게 생각해? 어떤 아이디어가 이것을 달성하는 방법?
거미 :
import scrapy
import json
class StationSpider(scrapy.Spider):
name = 'station'
start_urls = ['http://...']
def parse(self, response):
jsonResponse = json.loads(response.body_as_unicode())
for station in jsonResponse:
yield station
당신이 거미 안에 그것에게 scrapy 방법을 수행하기위한 몇 가지 코드를 보여줄 수 있습니까? 그것은 올바른 해결책 인 것 같습니다. –
거미의 코드를 공유해야합니다 (또는 적어도 나중에 확인하려는 URL로 항목을 생성하는 부분) – eLRuLL