1
사이트를 고치고 있으며 각 지역이 속한 국가 내에있는 xml을 생성하려고합니다. 내가으로 표시 할 수있는 XML은 다음 원하는거미집에서 XML을 올바르게 들여 쓰는 법
<Country1></Country1>
<Country2></Country2>
<Region>Region1</Region>
<Region>Region2</Region>
<Region>Region3</Region>
<Region>Region1</Region>
<Region>Region2</Region>
<Region>Region3</Region>
: 같은
def parse(self, response):
#here i parse the country names
country_names = response.xpath('//some countries/text()').extract()
for name_of_country in countries :
yield {"Country": name_of_country }
yield Request(country_url, callback=self.parse_regions)
def parse_regions(self, response):
#here i parse the regions of each country
regions= response.xpath('//some regions/text()').extract()
for region in regions
yield {"Region": region }
이제 XML이 나타납니다
<Country1>
<Region>Region1</Region>
<Region>Region2</Region>
<Region>Region3</Region>
</Country1>
<Country2>
<Region>Region1</Region>
<Region>Region2</Region>
<Region>Region3</Region>
</Country2>
보낼 수 있습니다 참조 -이
어쩌면 자신의 수출과 당신이
<region>
에<value>
을 변경하고<item>
을 제거 할 수 있습니다 제공하기 때문에솔루션은 완벽하지 않습니다 '요청 '(..., meta = { "국가": name_of_country})에서'meta ='를 사용하여 다음 요청에'국가 ' 요청을 사용하여 국가 및 모든 지역이 포함 된 항목 하나를 만들 수 있습니다. 단 하나의 지역이있는 항목은 많지 않습니다. – furas
우리가 테스트 할 수 있도록이 페이지에 url을 추가 할 수 있습니까? – furas