2016-10-05 3 views
0

Dies ist mein Code:Crapy Fehler IndentationError: erwartete einen gegliederter Block

from scrapy.spider import Spider 
from scrapy.selector import Selector 
from thuctapsinhvietnam.items import ThuctapsinhvietnamItem 


class ThuctapsinhvietnamSpider(Spider): 
    name = "thuctapsinhvietnam" 
    allowed_domains ["thuctapsinhvietnam.com"] 
    start_urls = [ 
     "http://www.thuctapsinhvietnam.com/thuctap-phuong-vinh-hao-3970.html" 
     ] 

    def parse(self, response): 
     def parse(self, response): 
     cases = Selector(response).xpath('//div[@id="areaThongTinCaNhan"]/table/tbody/tr[2]/td/table/tbody/tr/td/table/tbody/tr') 

     for case in cases: 
      item = ThuctapsinhvietnamItem() 
      item['Name'] = question.xpath(
       '//td[3][@class="thongtin"]/text()')extract()[0] 
      item['Phone'] = question.xpath(
       '//td[3][@class="thongtin"]/text()')extract()[0] 
      item['Email'] = question.xpath(
       '//td[3][@class="thongtin"]/text()')extract()[0] 
      item['Dob'] = question.xpath(
       '//td[3][@class="thongtin"]/text()')extract()[0] 
      item['Sex'] = question.xpath(
       '//td[3][@class="thongtin"]/text()')extract()[0] 
      item['School'] = question.xpath(
       '//td[3][@class="thongtin"]/text()')extract()[0] 
      item['Introduction'] = question.xpath(
       '//td[3][@class="thongtin"]/text()')extract()[0] 
      item['Place'] = question.xpath(
       '//td[3][@class="thongtin"]/text()')extract()[0] 
      yield item 

Ich habe Probleme beim Versuch in Ubuntu Scrapy, verwende ich XPath Daten zu erhalten. I scrapy Informationen von dieser Website ist versucht, aber es hat Fehler hier:

File "thuctapsinhvietnam_spider.py", line 15 
cases = Selector(response).xpath('//div[@id="areaThongTinCaNhan"]/table/tbody/tr[2]/td/table/tbody/tr/td/table/tbody/tr') 
    ^
IndentationError: expected an indented block 

Antwort

0

Sie haben zwei davon:

def parse(self, response): 
    def parse(self, response): 
Verwandte Themen