2013-07-31 1 views
0

Ce que j'essaie, c'est d'obtenir plusieurs pages Web à partir d'une liste prédéfinie. Voici le code:Web-Harvest: saisir plusieurs URL dans une liste

<?xml version="1.0" encoding="UTF-8"?> 
    <config> 

     <script> 
      <![CDATA[ 
       String[] codes = new String[] {"18","21","24","25","26"}; 
       SetContextVar("codes", codes); 
      ]]> 
     </script> 
     <loop item="link"> 
      <list> 
       <var name="codes" /> 
      </list> 
      <body> 

       <var-def name="webpage"> 
        <html-to-xml>         
        <http url="${sys.fullUrl('http://www.someurl.com/',link)}"/>    
        </html-to-xml> 
       </var-def> 
      </body> 
     </loop> 
    </config> 

et l'erreur est "affectation variable: codes: ne peut pas attribuer à org.webharvest.runtime.variables.ListVariable java.lang.String"

Qu'est-ce que suis-je manquant ici?

Répondre

1

S'il vous plaît essayer exmple:

<config> 

    <var-def name="Codes"> 
    <![CDATA[<Codes>]]> 
    <![CDATA[<Code>]]>18<![CDATA[</Code>]]> 
    <![CDATA[<Code>]]>21<![CDATA[</Code>]]> 
    <![CDATA[<Code>]]>24<![CDATA[</Code>]]> 
    <![CDATA[<Code>]]>25<![CDATA[</Code>]]> 
    <![CDATA[</Codes>]]> 
    </var-def> 

    <loop item="CodesLoop" index="i"> 
    <list> 
     <xpath expression="//Code/text()"> 
     <var name="Codes"/> 
     </xpath> 
    </list> 
    <body> 
     <file action="write" path="D:\ABC\${CodesLoop}.txt" charset="UTF-8"> 
     <template>${CodesLoop}</template> 
     </file> 
    </body> 
    </loop> 
</config> 
Questions connexes