回答編集履歴
2
追記
answer
CHANGED
@@ -23,4 +23,11 @@
|
|
23
23
|
content = result.xpath('./div[@class="text"]/div[@class="bangumi"]/text()').extract_first()
|
24
24
|
(あとは略)
|
25
25
|
```
|
26
|
-
こうかな?
|
26
|
+
こうかな?
|
27
|
+
|
28
|
+
----
|
29
|
+
何を直したのかわかっていないようなので。
|
30
|
+
|
31
|
+
せっかく要素を探索してループを回しているのに、その中で`//`から探索したら、常にルートノードから探索してしまって意味がないので、コンテキストノードの下を探すように書きました。
|
32
|
+
|
33
|
+
[http://www.techscore.com/tech/XML/XPath/xpath02.html/](http://www.techscore.com/tech/XML/XPath/xpath02.html/)
|
1
追記
answer
CHANGED
@@ -10,4 +10,17 @@
|
|
10
10
|
```
|
11
11
|
とでもすればいいんじゃないかと。
|
12
12
|
|
13
|
-
[https://docs.python.jp/3/reference/expressions.html#yieldexpr](https://docs.python.jp/3/reference/expressions.html#yieldexpr)
|
13
|
+
[https://docs.python.jp/3/reference/expressions.html#yieldexpr](https://docs.python.jp/3/reference/expressions.html#yieldexpr)
|
14
|
+
|
15
|
+
----
|
16
|
+
```
|
17
|
+
for result in info.xpath('//div[@class="syuroku_raiten_area"]/div[@class="hall_info"]'):
|
18
|
+
content = result.xpath('//div[@class="text"]/div[@class="bangumi"]/text()').extract_first()
|
19
|
+
```
|
20
|
+
↓
|
21
|
+
```
|
22
|
+
for result in info.xpath('.//div[@class="hall_info"]'):
|
23
|
+
content = result.xpath('./div[@class="text"]/div[@class="bangumi"]/text()').extract_first()
|
24
|
+
(あとは略)
|
25
|
+
```
|
26
|
+
こうかな?
|