嗨,我正在基于 python 语言在 scrapy 框架中编写蜘蛛。我正在尝试以下代码,但它给了我一个意想不到的缩进,我没有找到类似的东西。我全新这是我在 python 中的第一个蜘蛛。请帮我
from scrapy.spider import BaseSpider
from scrapy.selector import HtmlXPathSelector
from first_sample.items import FirstSampleItem
class FirstSpider(BaseSpider):
name = "first"
allowed_domains = ["reviews42.com"]
start_urls = ["http://www.reviews42.com/mobiles/category/"]
def parse(self, response):
hxs = HtmlXPathSelector(response)
apps = hxs.select("//*[@id=\"col1\"]/div[@class=\"clear left summary-block relative\"]")
count = 0
items = []
for app in apps:
item = FirstSampleItem()
item['title'] = appa.select("//div[@class=\"padding10 relative\"]/div[@class=\"thin-heading font700 black marginTop5\"]/a/text()")[count].extract()
items.append(item)
count += 1
return items
IndentationError: unindent 不匹配任何外部缩进级别