获取空值,即使在scrapy shell中值不是nu

2024-09-29 23:21:38 发布

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

我得到了空值,即使在scrapy shell中,值不是空的

我已经尝试过删除这个链接:https://www.chemicalbook.com/ProductChemicalPropertiesCB2909992_EN.htm 要获得我使用的产品名称:

response.css('.ProdSupplierGN_ProductA_2 .td1+ td a::text').get()

但是当我看到输出时,我的数据是:

{
   "link":"https://www.chemicalbook.com/ProductChemicalPropertiesCB2909992_EN.htm",
   "name":null,
   "cas":null,
   "synomym":[

   ],
   "molecular_formula":null,
   "molecular_weight":null,
   "einecs":null,
   "product_categories":[

   ],
   "melting_point":null,
   "vapor_pressure":[

   ],
   "form":null,
   "henry_law_constant":null,
   "stability":null,
   "inchikey":null,
   "hazard_codes":null,
   "risk_statements":null,
   "safety_statements":null,
   "wgk":null,
   "tsca":null,
   "packing_group":null,
   "hs_code":null,
   "hazardous_substance_data":null,
   "chemical_properties":null,
   "definition":null,
   "air_and_water_reactions":null,
   "general_description":null,
   "reactivity_profile":null,
   "fire_hazard":null
}
    def parse_chemi_link(self, response):
        items = ChemibookItem()

        #------------------------------BASIC INFORMATION    
        link = response.url
        name = response.css('.ProdSupplierGN_ProductA_2 .td1+ td a::text').get()
        synomym = response.css('.ProdSupplierGN_ProductA_2+ .ProdSupplierGN_ProductA_2 td+ td font::text').getall()
        items['link'] = link
        items['name'] = name
        items['synomym'] = synomym
        yield items



Tags: textnamehttpscomresponsewwwlinkitems

热门问题