python - Scrapy尝试抓取网页的信息内部链接

标签 python scrapy

我正在尝试抓取页面JobStreet

我能够抓取主页上的信息,但当我尝试抓取页面的内部链接时,我的问题出现了,例如第一个帖子 here

这是我的代码片段:

import scrapy

from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy import Item, Field

class IT(scrapy.Spider):
    name = 'IT'

    allowed_domains = ["www.jobstreet.com.sg"]
    start_urls = [
        'https://www.jobstreet.com.sg/en/job-search/job-vacancy.php?key=&specialization=191%2C192%2C193&area=&salary=&ojs=3&src=12',
    ]

    rules = (
        Rule(SgmlLinkExtractor(allow=[r'/en/job/*.'], restrict_xpaths=('//*[(@class = "position-title-link")]',)), callback='parse_info', follow=True)
    )


    def parse_info(self, response):

        self.logger.info('response.url=%s' % response.url)

无法从 parse_info 获得任何类型的响应。

最佳答案

你可以改变

scrapy.Spider

CrawlSpider

关于python - Scrapy尝试抓取网页的信息内部链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45787869/

相关文章:

php - 无法从 PHP 文档执行 Python 脚本

python - scrapy scrapy 命令的 tab 补全

python - 爬虫进程意外死亡

python - NumPy 中 j 的等价物

python - 在 python 三元中使用 continue?

python - 使用 scrapy python 爬取 NodeJs 和 AngularJs 站点

python - 为什么我在 scrapy 上的所有项目都是一样的?

python - Scrapy - 激活项目管道组件 - ITEM_PIPELINES 设置

Python散点图索引错误

python - 在 Theano 中执行期间选择 GPU