您当前的位置: 首页 >  scrapy

壹小俊

暂无认证

  • 1浏览

    0关注

    885博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

爬虫第六课---scrapy(二)案例2,爬取腾讯招聘

壹小俊 发布时间:2019-04-21 15:43:23 ,浏览量:1

'''
1.
shell对象和selector对象
scrapy shell就是一个交互式的终端
作用:可以很好的调试
启动:scrapy shell url

如果url有参数,用引号把url包起来

2.选择器
selector
xpath
extract:返回unicode字符串
css
re
'''

 

废话不多说,直接上代码,然后解释。

spider代码

# -*- coding: utf-8 -*-
import scrapy
from ..items import TencentItem


class TencentSpider(scrapy.Spider):
    name = 'tencent'
    # allowed_domains = ['https://hr.tencent.com/position.php?&start=0#a']
    start_urls = ['https://hr.tencent.com/position.php?&start=0#a']
    base_url = 'https://hr.tencent.com/'

    def parse(self, response):
        names = response.xpath('//tr[@class="even"]/td[1]/a/text() | //tr[@class="odd"]/td[1]/a/text()').extract()
        types = response.xpath('//tr[@cl
关注
打赏
1664335782
查看更多评论
立即登录/注册

微信扫码登录

0.0410s