次の例を使用します。
$ scrapy shell http://doc.scrapy.org/en/latest/_static/selectors-sample1.html
どこにselectors-sample1-html
ある:
<html>
<head>
<base href='http://example.com/' />
<title>Example website</title>
</head>
<body>
<div id='images'>
<a href='image1.html'>Name: My image 1 <br /><img src='image1_thumb.jpg' /></a>
<a href='image2.html'>Name: My image 2 <br /><img src='image2_thumb.jpg' /></a>
<a href='image3.html'>Name: My image 3 <br /><img src='image3_thumb.jpg' /></a>
<a href='image4.html'>Name: My image 4 <br /><img src='image4_thumb.jpg' /></a>
<a href='image5.html'>Name: My image 5 <br /><img src='image5_thumb.jpg' /></a>
</div>
</body>
</html>
Scrapy 1.1.2 を使用してマッチの行番号を取得することは可能ですか? たとえば、次のようなものです。
$ response.selector.xpath('//title/text()').some_magic_to_get_line_number
$ # should output 4
ありがとうございました!