from  boss.items.=  import  BossItem

class  ZhiPinSpider(CrwalSpider):
    name='Zhipin'
    allwed_domains=['zhipin.com']
    start_urls=['https://www.zhipin.com/c100010000/?query=python&page=1']

    rules={
        #匹配职位列表页的规则
        Rule(LinkExtractor(allow=r'.+\?query=python&page=\d'),follow=True)

        #匹配职位详情页的规则
        Rule(LinkExtractor(allow=r'.+\?query=python&page=\d'),callback="parse_job",follow=False)

    def  parse_job(self,response):
        title=response.xpath('//h1[@class="name"]/text()').get().strip()
        company=response.xpath('//div[@class="info-company"]//a/text()').get()
        item=BossItem(title=title,company=company)
        yield  item

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。