码迷,mamicode.com
首页 > 其他好文 > 详细

scrapy yield Request

时间:2015-05-03 20:27:36      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:

import scrapy
from myproject.items import MyItem
class MySpider(scrapy.Spider):
name = ’example.com’ allowed_domains = [’example.com’] start_urls = [
        ’http://www.example.com/1.html’,
        ’http://www.example.com/2.html’,
        ’http://www.example.com/3.html’,
]
def parse(self, response):   for h3 in response.xpath(’//h3’).extract():     yield MyItem(title=h3)
  
for url in response.xpath(’//a/@href’).extract():
    yield scrapy.Request(url, callback=self.parse)

 

scrapy yield Request

标签:

原文地址:http://www.cnblogs.com/feika/p/4474466.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!