Я знаю, что мне нужно работать с моими селекторами, чтобы настраивать более конкретные данные, но я не знаю, почему мой csv является ПУСТОЙ.Python: Scrapy spider не возвращает результаты?
мой класс синтаксического анализа:
class MySpider(BaseSpider):
name = "wikipedia"
allowed_domains = ["en.wikipedia.org/"]
start_urls = ["http://en.wikipedia.org/wiki/2014_in_film"]
def parse(self, response):
hxs = HtmlXPathSelector(response)
titles = hxs.select('//table[@class="wikitable sortable jquery-tablesorter"], [@style="margin:auto; margin:auto;"]')
items = []
for title in titles:
item = WikipediaItem()
item["title"] = title.select("td/text()").extract()
item["url"] = title.select("a/text()").extract()
items.append(item)
return items
HTML, я пытаюсь ползать:
<table class="wikitable sortable" style="margin:auto; margin:auto;">
<caption>Highest-grossing films of 2014</caption>
<tr>
<th>Rank</th>
<th>Title</th>
<th>Studio</th>
<th>Worldwide gross</th>
</tr>
<tr>
<th style="text-align:center;">1</th>
<td><i><a href="/wiki/Transformers:_Age_of_Extinction" title="Transformers: Age of Extinction">Transformers: Age of Extinction</a></i></td>
<td><a href="/wiki/Paramount_Pictures" title="Paramount Pictures">Paramount Pictures</a></td>
<td>$1,091,404,499</td>
</tr>
И этот раздел в HTML повторяется снова и снова для каждого фильма, поэтому он должен захватить все как только правильно выбрано:
<tr>
<th style="text-align:center;">1</th>
<td><i><a href="/wiki/Transformers:_Age_of_Extinction" title="Transformers: Age of Extinction">Transformers: Age of Extinction</a></i></td>
<td><a href="/wiki/Paramount_Pictures" title="Paramount Pictures">Paramount Pictures</a></td>
<td>$1,091,404,499</td>
</tr>
Я знаю, что проблема не в экспорте, потому что даже в моей оболочке говорится: «Craw l 0 страниц, Скребок 0 Элементы «так что ничто не тронуто.
Что касается селекторов , Я понятия не имею, насколько конкретно ** требуется **, поэтому это может быть легко ошибкой. –