【发布时间】:2019-03-17 15:08:35
【问题描述】:
我正在尝试从以下页面提取地址名称:https://property.spatialest.com/nc/durham/#/property/100016
property_spider.py:
from scrapy import Spider
from scrapy.selector import Selector
from property.items import PropertyItem
class PropertySpider(Spider):
name = "property"
allowed_domains = ["property.spatialest.com"]
start_urls = [
"http://property.spatialest.com/nc/durham/#/property/100016"
]
def parse(self, response):
address = Selector(response).xpath("//html/body/main/div/div[2]/div/div[1]/div[2]/div/section/div/div[1]/div[2]/header/div/div/div[1]/div[2]/span")
address_item = PropertyItem()
address_item['address'] = address.xpath('span[@class="value "]/text()').extract()
yield address_item
蜘蛛每次都返回{'address': []}。我认为我告诉它提取数据的方式可能有问题..
更新:
看起来它没有提取任何数据,因为请求在“#”处被切断
RESPONSE: <200 https://property.spatialest.com/nc/durham/>
2019-03-16 13:59:12 [scrapy.core.scraper] DEBUG: Scraped from <200 https://property.spatialest.com/nc/durham/>
{'address': []}```
【问题讨论】:
-
该网站使用 Javascript 呈现内容。 Scrapy 本身无法做到这一点。看看 Scrapy Splash:github.com/scrapy-plugins/scrapy-splash
标签: python scrapy web-crawler