规则做对了,在爬数据的时候,发现有些数据抓到了,有些数据没有抓到
链接地址 http://www.atobo.com.cn/Companys/s-p17-s406-c1-k3352-y4/
数据规则<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:svg="http://www.w3.org/2000/svg" >
<xsl:template match="/">
<标题>
<xsl:apply-templates select="//*[@class='product_contextlist bplist']/ul/li[position()>=1 and count(.//*[@class='CompanyName'])>0 and count(.//*[@class='pp_product'])>0 and count(.//*[@class='c_name']/strong/text())>0 and count(.//*[@class='pp_2web']/strong/a[position()=1]/@href)>0]" mode="标题"/>
</标题>
</xsl:template>
<xsl:template match="//*[@class='product_contextlist bplist']/ul/li[position()>=1 and count(.//*[@class='CompanyName'])>0 and count(.//*[@class='pp_product'])>0 and count(.//*[@class='c_name']/strong/text())>0 and count(.//*[@class='pp_2web']/strong/a[position()=1]/@href)>0]" mode="标题">
<item>
<公司名称>
<xsl:value-of select="*//*[@class='CompanyName']"/>
<xsl:value-of select="*[@class='CompanyName']"/>
</公司名称>
<主营>
<xsl:value-of select="*//*[@class='pp_product']"/>
<xsl:value-of select="*[@class='pp_product']"/>
</主营>
<地址>
<xsl:value-of select="*//*[@class='pp_address']/strong/text()"/>
<xsl:value-of select="*[@class='pp_address']/strong/text()"/>
<xsl:if test="@class='pp_address'">
<xsl:value-of select="strong/text()"/>
</xsl:if>
</地址>
<联系人>
<xsl:value-of select="*//*[@class='c_name']/strong/text()"/>
<xsl:value-of select="*[@class='c_name']/strong/text()"/>
<xsl:if test="@class='c_name'">
<xsl:value-of select="strong/text()"/>
</xsl:if>
</联系人>
<网址>
<xsl:value-of select="*//*[@class='pp_2web']/strong/a[position()=1]/@href"/>
<xsl:value-of select="*[@class='pp_2web']/strong/a[position()=1]/@href"/>
<xsl:if test="@class='pp_2web'">
<xsl:value-of select="strong/a[position()=1]/@href"/>
</xsl:if>
</网址>
</item>
</xsl:template>
</xsl:stylesheet>
输出信息:<?xml version="1.0" encoding="UTF-8"?>
<标题>
<item>
<公司名称>南京钢加工程机械实业有限公司溧阳分公司</公司名称>
<主营>主营:普通机械及配件,汽车(不含小轿车)及配件,电器机械及器材,日用杂品,建筑工程机械租凭</主营>
<地址>台港新村公建6-11轴</地址>
<联系人>段立中 业务经理</联系人>
<网址>http://09s9476535.atobo.com.cn</网址>
</item>
只显示5个输出漏抓了15个
file:///C:\Users\steven\AppData\Roaming\Tencent\Users\1192599412\QQ\WinTemp\RichOle\R%GXL3V}8_Z70VHI)X)M3CG.png
|
|
|
|
|
共 24 个关于本帖的回复 最后回复于 2017-3-21 21:46