这是我的主要蜘蛛巴苏尼.py在
from scrapy.spider import Spider
from scrapy.selector import Selector
from bathUni.items import BathuniItem
class bathuni(Spider):
name = "bathU"
allowed_domains = ["http://international.southwales.ac.uk/"]
start_urls= ["http://international.southwales.ac.uk/country/argentina/en/",
"http://international.southwales.ac.uk/country/france/en/",
"http://international.southwales.ac.uk/country/australia/en/"]
def parse(self, response):
sel = Selector(response)
sites = sel.xpath('//div[@class="factsheet"]/ul/li')
for site in sites:
country = site.xpath('text()').extract()
return country
我的项目.py具体如下:
^{pr2}$我用来输出到csv文件的命令是
scrapy crawl bathU -o countries.csv -t csv
我的输出文件总是空的。任何帮助都将不胜感激。谢谢。在
将
return country
更改为yield BathuniItem(Country=country)
这解决了两个问题:
ERROR: Spider must return Request, BaseItem or None, got 'unicode'
相关问题 更多 >
编程相关推荐