在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/人工智能/ 網(wǎng)站的翻頁鏈接都顯示成一個 # ,還能用crawl spider嗎

網(wǎng)站的翻頁鏈接都顯示成一個 # ,還能用crawl spider嗎

http://house.njhouse.com.cn/r...
網(wǎng)站的翻頁鏈接都顯示成一個 # ,還能用crawl spider嗎。
圖片描述
如果能用的話這個網(wǎng)站的rules該怎么寫。
我寫的這個不行額

rules = [
Rule(LinkExtractor(allow=('/rent/houselist/p-d+',)),callback='parse_item', follow=True),

]



下面是我的爬蟲主要代碼,該怎么修改。

class ListSpider(CrawlSpider):

# 爬蟲名稱
name = "nanjingtenement"
# 允許域名
allowed_domains = ["njhouse.com.cn"]
# 開始URL
start_urls = ['http://house.njhouse.com.cn/rent/houselist/p-1'
]
rules = [
    Rule(LinkExtractor(allow=(r'/rent/houselist/p-'+ '\d+' ,)),callback='parse_item', follow=True),
]
# 解析內(nèi)容函數(shù)
def parse_item(self, response):
    for sel in response.xpath('//div[@class="list_main_lists"]/ul/li[not(@id)]'):
        item = NanjingItem()
        link = sel.xpath('a/@href')[0].extract()
        item['link'] = link
        pageno=response.selector.xpath('//div[@class="pagination-container"]/a[@class="active btn-active-filter"]/text()')[0].extract()
        item['pageno'] = pageno
        listingchannel=sel.xpath('div/p/text()')[0].extract()
        item['listingchannel'] = listingchannel
        yield item
回答
編輯回答
憶往昔

取data-index就好了,分頁url是http://house.njhouse.com.cn/r...
只需用把'http://house.njhouse.com.cn/r...'拼接上頁碼就可以了。

或者

觀察有多少頁碼直接循環(huán)拼接出所有分頁的url就可以。

2017年4月29日 19:52