这是我的代码:
import scrapy
from scrapy.selector import Selector
from testtest.items import TesttestItem
import datetime
class MySpider(scrapy.Spider):
name = "A1storage"
allowed_domains = ['https://www.a1lockerrental.com']
start_urls = ['http://www.a1lockerrental.com/self-storage/mo/st-
louis/4427-meramec-bottom-rd-facility/unit-sizes-prices#/units?
category=all']
def parse(self, response):
info = response.css('buttons')
for i in info:
yield {
"special": i.css(".special-text").extract_first(),
"rate": i.css(".active .cat-price").extract(),
"size": i.css(".sss-unit-size::text").extract(),
"types": i.css(".sss-unit-amenitie
span::text").extract_first()
}
无论我将选择器更改为响应变量,我都不返回任何内容。我认为网站本身的HTML有问题,但我不够熟悉它。