# -*- coding: utf-8 -*-
import scrapy
from scrapy.contrib.linkextractors import LinkExtractor
from scrapy.contrib.spiders import CrawlSpider, Rule

from romdownloader.items import FileItem


class CmSpider(CrawlSpider):
    name = 'miui'
    allowed_domains = ['www.romzj.com']
    start_urls = [
        'http://www.romzj.com/rom/2976.htm',
        'http://www.romzj.com/rom/1045.htm',
        'http://www.romzj.com/rom/7945.htm',
        'http://www.romzj.com/rom/6766.htm',
        'http://www.romzj.com/rom/5548.htm',
        'http://www.romzj.com/rom/5419.htm',
        'http://www.romzj.com/rom/28375.htm',
        'http://www.romzj.com/rom/22519.htm',
        'http://www.romzj.com/rom/22839.htm',
        'http://www.romzj.com/rom/21912.htm',
        'http://www.romzj.com/rom/21916.htm',
        'http://www.romzj.com/rom/23544.htm',
        'http://www.romzj.com/rom/31767.htm',
        'http://www.romzj.com/rom/31222.htm',
        'http://www.romzj.com/rom/25118.htm',
        'http://www.romzj.com/rom/22836.htm',
        'http://www.romzj.com/rom/30643.htm',
        'http://www.romzj.com/rom/30383.htm',
        'http://www.romzj.com/rom/24143.htm',
        'http://www.romzj.com/rom/30773.htm',
        'http://www.romzj.com/rom/11109.htm',
        'http://www.romzj.com/rom/31555.htm',
        'http://www.romzj.com/rom/31170.htm',
        'http://www.romzj.com/rom/31335.htm',
        'http://www.romzj.com/rom/31288.htm',
        'http://www.romzj.com/rom/31280.htm',
        'http://www.romzj.com/rom/30973.htm',
        'http://www.romzj.com/rom/29819.htm',
        'http://www.romzj.com/rom/27990.htm',
        'http://www.romzj.com/rom/29248.htm',
        'http://www.romzj.com/rom/22518.htm',
        'http://www.romzj.com/rom/27540.htm',
        'http://www.romzj.com/rom/29380.htm',
        'http://www.romzj.com/rom/28376.htm',
        'http://www.romzj.com/rom/27799.htm',
        'http://www.romzj.com/rom/21913.htm',
        'http://www.romzj.com/rom/4506.htm',
        'http://www.romzj.com/rom/4541.htm',
        'http://www.romzj.com/rom/4557.htm',
        'http://www.romzj.com/rom/4536.htm',
        'http://www.romzj.com/rom/4538.htm',
        'http://www.romzj.com/rom/4539.htm',
        'http://www.romzj.com/rom/4543.htm',
        'http://www.romzj.com/rom/536.htm',
        'http://www.romzj.com/rom/396.htm',
        'http://www.romzj.com/rom/619.htm',
        'http://www.romzj.com/rom/374.htm',
        'http://www.romzj.com/rom/145.htm',
        'http://www.romzj.com/rom/27984.htm',
        'http://www.romzj.com/rom/29811.htm',
        'http://www.romzj.com/rom/28091.htm',
        'http://www.romzj.com/rom/29810.htm',
        'http://www.romzj.com/rom/28094.htm',
        'http://www.romzj.com/rom/27986.htm',
        'http://www.romzj.com/rom/30953.htm',
        'http://www.romzj.com/rom/31197.htm',
        'http://www.romzj.com/rom/31374.htm',
        'http://www.romzj.com/rom/30970.htm',
        'http://www.romzj.com/rom/30781.htm',
        'http://www.romzj.com/rom/25692.htm',
        'http://www.romzj.com/rom/8062.htm',
        'http://www.romzj.com/rom/9832.htm',
        'http://www.romzj.com/rom/8780.htm',
        'http://www.romzj.com/rom/15248.htm',
        'http://www.romzj.com/rom/5228.htm',
        'http://www.romzj.com/rom/3821.htm',
        'http://www.romzj.com/rom/3950.htm',
        'http://www.romzj.com/rom/937.htm',
        'http://www.romzj.com/rom/2565.htm',
        'http://www.romzj.com/rom/2410.htm',
        'http://www.romzj.com/rom/2183.htm',
        'http://www.romzj.com/rom/770.htm',
        'http://www.romzj.com/rom/1812.htm',
        'http://www.romzj.com/rom/1151.htm',
        'http://www.romzj.com/rom/7039.htm',
        'http://www.romzj.com/rom/2551.htm',
        'http://www.romzj.com/rom/5531.htm',
        'http://www.romzj.com/rom/28385.htm',
        'http://www.romzj.com/rom/31234.htm',
        'http://www.romzj.com/rom/30640.htm',
        'http://www.romzj.com/rom/30377.htm',
        'http://www.romzj.com/rom/27552.htm',
        'http://www.romzj.com/rom/25494.htm',
        'http://www.romzj.com/rom/29227.htm',
        'http://www.romzj.com/rom/22568.htm',
        'http://www.romzj.com/rom/22355.htm',
        'http://www.romzj.com/rom/21153.htm',
        'http://www.romzj.com/rom/21910.htm',
        'http://www.romzj.com/rom/21746.htm',
        'http://www.romzj.com/rom/31766.htm',
        'http://www.romzj.com/rom/31199.htm',
        'http://www.romzj.com/rom/30971.htm',
        'http://www.romzj.com/rom/30777.htm',
        'http://www.romzj.com/rom/2220.htm',
        'http://www.romzj.com/rom/1836.htm',
        'http://www.romzj.com/rom/504.htm',
        'http://www.romzj.com/rom/499.htm',
        'http://www.romzj.com/rom/9550.htm',
        'http://www.romzj.com/rom/9831.htm',
        'http://www.romzj.com/rom/12991.htm',
        'http://www.romzj.com/rom/8782.htm',
        'http://www.romzj.com/rom/14751.htm',
        'http://www.romzj.com/rom/32050.htm',
        'http://www.romzj.com/rom/31849.htm',
        'http://www.romzj.com/rom/31655.htm',
        'http://www.romzj.com/rom/31685.htm',
        'http://www.romzj.com/rom/22521.htm',
        'http://www.romzj.com/rom/28377.htm',
        'http://www.romzj.com/rom/25119.htm',
        'http://www.romzj.com/rom/27798.htm',
        'http://www.romzj.com/rom/27541.htm',
        'http://www.romzj.com/rom/24144.htm',
        'http://www.romzj.com/rom/22266.htm',
        'http://www.romzj.com/rom/17890.htm',
        'http://www.romzj.com/rom/21915.htm',
        'http://www.romzj.com/rom/21918.htm',
        'http://www.romzj.com/rom/23542.htm',
        'http://www.romzj.com/rom/22837.htm',
        'http://www.romzj.com/rom/32108.htm',
        'http://www.romzj.com/rom/31852.htm',
        'http://www.romzj.com/rom/31684.htm',
        'http://www.romzj.com/rom/31686.htm',
        'http://www.romzj.com/rom/24362.htm',
        'http://www.romzj.com/rom/26918.htm',
        'http://www.romzj.com/rom/22499.htm',
        'http://www.romzj.com/rom/17969.htm',
        'http://www.romzj.com/rom/19361.htm',
        'http://www.romzj.com/rom/16422.htm',
        'http://www.romzj.com/rom/18897.htm',
        'http://www.romzj.com/rom/7771.htm',
        'http://www.romzj.com/rom/18242.htm',
        'http://www.romzj.com/rom/21986.htm',
        'http://www.romzj.com/rom/6319.htm',
        'http://www.romzj.com/rom/5856.htm',
        'http://www.romzj.com/rom/19169.htm',
        'http://www.romzj.com/rom/6327.htm',
        'http://www.romzj.com/rom/16353.htm',
        'http://www.romzj.com/rom/5178.htm',
        'http://www.romzj.com/rom/7051.htm',
        'http://www.romzj.com/rom/5175.htm',
        'http://www.romzj.com/rom/16164.htm',
        'http://www.romzj.com/rom/4545.htm',
        'http://www.romzj.com/rom/4594.htm',
        'http://www.romzj.com/rom/8124.htm',
        'http://www.romzj.com/rom/4589.htm',
        'http://www.romzj.com/rom/5039.htm',
        'http://www.romzj.com/rom/31341.htm',
        'http://www.romzj.com/rom/15775.htm',
        'http://www.romzj.com/rom/25495.htm',
        'http://www.romzj.com/rom/21745.htm',
        'http://www.romzj.com/rom/30974.htm',
        'http://www.romzj.com/rom/21248.htm',
        'http://www.romzj.com/rom/29374.htm',
        'http://www.romzj.com/rom/19688.htm',
        'http://www.romzj.com/rom/24295.htm',
        'http://www.romzj.com/rom/28388.htm',
        'http://www.romzj.com/rom/20994.htm',
        'http://www.romzj.com/rom/15777.htm',
        'http://www.romzj.com/rom/28092.htm',
        'http://www.romzj.com/rom/29809.htm',
        'http://www.romzj.com/rom/27985.htm',
        'http://www.romzj.com/rom/11686.htm',
        'http://www.romzj.com/rom/22641.htm',
        'http://www.romzj.com/rom/22358.htm',
        'http://www.romzj.com/rom/31770.htm',
        'http://www.romzj.com/rom/31223.htm',
        'http://www.romzj.com/rom/30644.htm',
        'http://www.romzj.com/rom/29377.htm',
        'http://www.romzj.com/rom/27994.htm',
        'http://www.romzj.com/rom/29324.htm',
        'http://www.romzj.com/rom/24651.htm',
        'http://www.romzj.com/rom/27223.htm',
        'http://www.romzj.com/rom/17464.htm',
        'http://www.romzj.com/rom/30641.htm',
        'http://www.romzj.com/rom/25098.htm',
        'http://www.romzj.com/rom/22359.htm',
        'http://www.romzj.com/rom/29821.htm',
        'http://www.romzj.com/rom/29692.htm',
        'http://www.romzj.com/rom/29325.htm',
        'http://www.romzj.com/rom/29226.htm',
        'http://www.romzj.com/rom/15654.htm',
        'http://www.romzj.com/rom/21244.htm',
        'http://www.romzj.com/rom/15907.htm',
        'http://www.romzj.com/rom/15508.htm',
        'http://www.romzj.com/rom/19936.htm',
        'http://www.romzj.com/rom/5455.htm',
        'http://www.romzj.com/rom/30543.htm',
        'http://www.romzj.com/rom/25693.htm',
        'http://www.romzj.com/rom/24647.htm',
        'http://www.romzj.com/rom/8302.htm',
        'http://www.romzj.com/rom/31769.htm',
        'http://www.romzj.com/rom/11687.htm',
        'http://www.romzj.com/rom/22357.htm',
        'http://www.romzj.com/rom/29376.htm',
        'http://www.romzj.com/rom/29691.htm',
        'http://www.romzj.com/rom/29326.htm',
        'http://www.romzj.com/rom/22951.htm',
        'http://www.romzj.com/rom/15659.htm',
        'http://www.romzj.com/rom/5323.htm',
        'http://www.romzj.com/rom/22073.htm',
        'http://www.romzj.com/rom/16175.htm',
        'http://www.romzj.com/rom/8720.htm',
        'http://www.romzj.com/rom/5035.htm',
        'http://www.romzj.com/rom/5838.htm',
        'http://www.romzj.com/rom/5053.htm',
        'http://www.romzj.com/rom/10781.htm',
        'http://www.romzj.com/rom/8126.htm',
        'http://www.romzj.com/rom/5792.htm',
        'http://www.romzj.com/rom/4314.htm',
        'http://www.romzj.com/rom/5165.htm',
        'http://www.romzj.com/rom/15180.htm',
        'http://www.romzj.com/rom/11683.htm',
        'http://www.romzj.com/rom/9517.htm',
        'http://www.romzj.com/rom/11952.htm',
        'http://www.romzj.com/rom/5820.htm',
        'http://www.romzj.com/rom/5248.htm',
        'http://www.romzj.com/rom/11938.htm',
        'http://www.romzj.com/rom/11647.htm',
        'http://www.romzj.com/rom/7910.htm',
        'http://www.romzj.com/rom/5756.htm',
        'http://www.romzj.com/rom/9548.htm',
        'http://www.romzj.com/rom/12171.htm',
        'http://www.romzj.com/rom/2261.htm',
        'http://www.romzj.com/rom/2018.htm',
        'http://www.romzj.com/rom/30642.htm',
        'http://www.romzj.com/rom/27542.htm',
        'http://www.romzj.com/rom/25120.htm',
        'http://www.romzj.com/rom/29379.htm',
        'http://www.romzj.com/rom/24145.htm',
        'http://www.romzj.com/rom/28378.htm',
        'http://www.romzj.com/rom/27797.htm',
        'http://www.romzj.com/rom/22267.htm',
        'http://www.romzj.com/rom/22522.htm',
        'http://www.romzj.com/rom/21914.htm',
        'http://www.romzj.com/rom/21919.htm',
        'http://www.romzj.com/rom/23543.htm',
        'http://www.romzj.com/rom/30379.htm',
        'http://www.romzj.com/rom/25487.htm',
        'http://www.romzj.com/rom/27551.htm',
        'http://www.romzj.com/rom/29151.htm',
        'http://www.romzj.com/rom/24293.htm',
        'http://www.romzj.com/rom/22567.htm',
        'http://www.romzj.com/rom/28292.htm',
        'http://www.romzj.com/rom/24887.htm',
        'http://www.romzj.com/rom/25121.htm',
        'http://www.romzj.com/rom/22354.htm',
        'http://www.romzj.com/rom/21911.htm',
        'http://www.romzj.com/rom/21819.htm',
        'http://www.romzj.com/rom/7650.htm',
        'http://www.romzj.com/rom/7435.htm',
        'http://www.romzj.com/rom/8367.htm',
        'http://www.romzj.com/rom/4897.htm',
        'http://www.romzj.com/rom/6351.htm',
        'http://www.romzj.com/rom/6230.htm',
        'http://www.romzj.com/rom/7129.htm',
        'http://www.romzj.com/rom/6761.htm',
        'http://www.romzj.com/rom/2199.htm',
        ]
    
    def parse(self, response):
#        url1s = response.xpath('//div[@class="nd_row_right_titlenr"]/a/@href').extract()
#        url1s = response.xpath('//div[@class="zy_lr_le_jz"]/a/@href').extract()
        url1s = response.xpath('//a[@id="detail_ptdl"]/@href').extract()
        for url1 in url1s:
            item = FileItem()
            item['url'] = url1
            yield item
        
#        url2s = response.xpath('//a[@class="btn_5"]/@href').extract()
#        for url2 in url2s:
       #     item = FileItem()
       #     item['url'] = url2
#            yield item
        
#        i = RomdownloaderItem()
        #i['domain_id'] = response.xpath('//input[@id="sid"]/@value').extract()
        #i['name'] = response.xpath('//div[@id="name"]').extract()
       # #i['description'] = response.xpath('//div[@id="description"]').extract()
#        return i
