Scrapy 1.3.3 xpath无法解析upnp xml文件

时间:2017-04-18 10:04:25

标签: xml xpath scrapy

<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
    <specVersion>
        <major>1</major>
        <minor>0</minor>
    </specVersion>
    <device>
        <deviceType>urn:schemas-upnp-org:device:InternetGatewayDevice:1</deviceType>
        <friendlyName>Linux Internet Gateway Device</friendlyName>
        <manufacturer>Linux UPnP IGD Project</manufacturer>
        <manufacturerURL>http://linux-igd.sourceforge.net</manufacturerURL>
        <modelName>IGD Version 1.00</modelName>
        <UDN>uuid:75802409-bccb-40e7-8e6c-fa095ecce13e</UDN>
        <DeviceType>Fiberhome_IGD_Device</DeviceType>
      <ProvisioningCode>NULL</ProvisioningCode> 
      <SoftwareVersion>1.0</SoftwareVersion> 
      <HardwareVersion>1.0</HardwareVersion> 
      <ManufacturerOUI>000AC2</ManufacturerOUI> 
      <ProductClass>Fiberhome_UPnP_Device</ProductClass> 
      <SerialNumber>01234560890123456</SerialNumber>            
        <iconList>
            <icon>
                <mimetype>image/gif</mimetype>
                <width>118</width>
                <height>119</height>
                <depth>8</depth>
                <url>/ligd.gif</url>
            </icon>
        </iconList>
        <serviceList>
                        <service>
                                <serviceType>urn:schemas-dummy-com:service:Dummy:1</serviceType>
                                <serviceId>urn:dummy-com:serviceId:dummy1</serviceId>
                            <controlURL>/dummy</controlURL>
                                <eventSubURL>/dummy</eventSubURL>
                    <SCPDURL>/dummy.xml</SCPDURL>
                        </service>
                </serviceList>
        <deviceList>
            <device>
                <deviceType>urn:schemas-upnp-org:device:WANDevice:1</deviceType>
                <friendlyName>WANDevice</friendlyName>
                <manufacturer>Linux UPnP IGD Project</manufacturer>
                <manufacturerURL>http://linux-igd.sourceforge.net</manufacturerURL>
                <modelDescription>WAN Device on Linux IGD</modelDescription>
                <modelName>Linux IGD</modelName>
                <modelNumber>1.00</modelNumber>
                <modelURL>http://linux-igd.sourceforge.net</modelURL>
                <serialNumber>1.00</serialNumber>
                <UDN>uuid:75802409-bccb-40e7-8e6c-fa095ecce13e</UDN>
                <UPC>Linux IGD</UPC>
                <ProvisioningCode>NULL</ProvisioningCode> 
              <SoftwareVersion>1.0</SoftwareVersion> 
              <DeviceType>Fiberhome_IGD_Device_1</DeviceType> 
              <HardwareVersion>1.0</HardwareVersion> 
              <ManufacturerOUI>000AC2</ManufacturerOUI> 
              <ProductClass>Fiberhome_UPnP_Device_1</ProductClass>              
                <serviceList>
                    <service>
                        <serviceType>urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1</serviceType>
                        <serviceId>urn:upnp-org:serviceId:WANCommonIFC1</serviceId>
                        <controlURL>/upnp/control/WANCommonIFC1</controlURL>
                        <eventSubURL>/upnp/control/WANCommonIFC1</eventSubURL>
                        <SCPDURL>/gateicfgSCPD.xml</SCPDURL>
                    </service>
                </serviceList>
                <deviceList>
                    <device>
                        <deviceType>urn:schemas-upnp-org:device:WANConnectionDevice:1</deviceType>
                        <friendlyName>WANConnectionDevice</friendlyName>
                        <manufacturer>Linux UPnP IGD Project</manufacturer>
                        <manufacturerURL>http://linux-igd.sourceforge.net</manufacturerURL>
                        <modelDescription>WanConnectionDevice on Linux IGD</modelDescription>
                        <modelName>Linux IGD</modelName>
                        <modelNumber>0.95</modelNumber>
                        <modelURL>http://linux-igd.sourceforge.net</modelURL>
                        <serialNumber>0.95</serialNumber>
                        <UDN>uuid:75802409-bccb-40e7-8e6c-fa095ecce13e</UDN>
                        <UPC>Linux IGD</UPC>
                        <ProvisioningCode>NULL</ProvisioningCode> 
                      <SoftwareVersion>1.0</SoftwareVersion> 
                      <DeviceType>Fiberhome_IGD_Device_2</DeviceType> 
                      <HardwareVersion>1.0</HardwareVersion> 
                      <ManufacturerOUI>000AC2</ManufacturerOUI> 
                      <ProductClass>Fiberhome_UPnP_Device_2</ProductClass>                      
                        <serviceList>
                            <service>
                                <serviceType>urn:schemas-upnp-org:service:WANIPConnection:1</serviceType>
                                <serviceId>urn:upnp-org:serviceId:WANIPConn1</serviceId>
                                <controlURL>/upnp/control/WANIPConn1</controlURL>
                                <eventSubURL>/upnp/control/WANIPConn1</eventSubURL>
                                <SCPDURL>/gateconnSCPD.xml</SCPDURL>
                            </service>
                        </serviceList>
                    </device>
                </deviceList>
            </device>
        </deviceList>
    </device>
</root>

这是一个upnp xml文件,我想使用scrapy来抓取它,但是当我使用scrapy shell获取上面的xml内容时,view(response)命令结果很好,一切看起来都不错,但是当我执行 response.xpath('//root')response.xpath('//manufacturer')response.xpath('//device') 我注意到了,我不知道为什么?这是一个scrapy xpath bug? 有人可以帮帮我吗?谢谢。 顺便说一句,请原谅我丑陋的英语......

0 个答案:

没有答案