我试着把我糟糕的结果输出到一个csv文件中,但是我的输出总是毫无意义

2024-09-30 01:21:29 发布

您现在位置:Python中文网/ 问答频道 /正文

这是我的主要蜘蛛巴苏尼.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

我的输出文件总是空的。任何帮助都将不胜感激。谢谢。在


Tags: csvfrompyimporthttpcountryselectorac

热门问题