网站的翻页链接都显示成一个 # ,还能用crawl spider吗

http://house.njhouse.com.cn/r...
网站的翻页链接都显示成一个 # ,还能用crawl spider吗。
图片描述
如果能用的话这个网站的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),
]
# 解析内容函数
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
阅读 1.9k
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进