美文网首页
scrapy中爬取的中文key变为英文key

scrapy中爬取的中文key变为英文key

作者: _Haimei | 来源:发表于2018-06-06 11:17 被阅读19次
    coninfos = response.xpath('//*[@id="app"]/div[3]/div/div[2]/main/div[2]/div/div')
    datadict = {"状态":"status","货币符号":"symbol","开始日期":"start_date","结束日期":"end_date","目标下限":"soft_cap","目标上限":"hard_cap","初始价格":"initial_price","代币数":"token_supply","募集金额":"collection_amount"}
        for coninfo in coninfos:
            key = coninfo.xpath('./div[1]/text()').get()
            value = coninfo.xpath('./div[2]/text()').get()
            item[datadict[key]] = value
    

    相关文章

      网友评论

          本文标题:scrapy中爬取的中文key变为英文key

          本文链接:https://www.haomeiwen.com/subject/tfcbsftx.html