代码之家  ›  专栏  ›  技术社区  ›  Chiefscreation

IMDB scrapy获取元内容中的电影日期

  •  1
  • Chiefscreation  · 技术社区  · 9 年前

    嗨,我想提取meta中的内容,这是电影的日期。如果我使用

    response.xpath("//*[@title='See more release dates']/meta").extract() 
    

    它只会让我到这里:

    [u'<meta itemprop="datePublished" content="1904-06-29">']
    

    如何在内容中获取日期?谢谢

    1 回复  |  直到 9 年前
        1
  •  1
  •   alecxe    9 年前

    获取 content 属性值通过 @content :

    response.xpath("//*[@title='See more release dates']/meta/@content").extract_first() 
    

    请注意,我正在使用 extract_first() 而不是 extract() 获取字符串值而不是列表。