def parse_detail(self, response):
yunbtv=response.meta['item']
yunbtv['info']=response.xpath('/html/body/section[2]/div/div/div[2]/div/text()[2]').extract()
print(yunbtv)
yield yunbtv
def parse(self, response):
#extract 提取
i=0
while (i<30):
names=response.xpath('//div[@class="card-heading text-ellipsis"]/strong/a/text()')[i].extract()
links=response.urljoin(response.xpath('//div[@class="card-heading text-ellipsis"]/strong/a/@href')[i].extract())
types=response.xpath('//div[@class="card-content text-ellipsis text-muted"]/a/@title')[i].extract()
yunbtv=YunbtvjectItem()
yunbtv['name']=names
yunbtv['link']=links
yunbtv['type']=types
yield scrapy.Request(
url=links,
callback=self.parse_detail,
meta={'item':yunbtv}
)
i = i +1