0

デバッグスパイダーを使用して分離したい属性を見つけることができましたが、スパイダーに正しく組み込まれているかどうかはわかりません。スパイダーの実行時に明示的なエラーメッセージが表示されないため、セレクターを間違って入力しただけだと思います。

私がクロールしている Web サイトは " http://www.smiling-moose.com/events/index.php " です。デバッグ スパイダーに入力するパス コマンドは "response.xpath('//div[@class=" show_sec_button"]/text()')" は、私が探している正確な応答を引き出します。

これが私のスパイダーです:

import scrapy

from smiling_moose.items import SMItem

class Smspider (scrapy.Spider):
    name = "smspider"
    allowed_domains = ["http://www.smiling-moose.com/index.php"]
    start_urls = [
         "http://www.smiling-moose.com/events/index.php",
    ]

def parse(self, response):
    for sel in response.xpath('//div'):
        item = SMItem()
        item['desc'] = response.xpath('//*[@class="show_sec_band"]/text()').extract()

ここに私のItems.pyがあります:

import scrapy


class SMItem(scrapy.Item):
    desc = scrapy.Field()

スパイダーで変更する必要があるものはありますか? 必要に応じて、コマンド プロンプト エラーを投稿できます。

ありがとうございました

4

1 に答える 1