简体   繁体   English

如何将网络采集数据保存到数据库

[英]how to save web-harvest data to database

I am scrapping the data using web-harvest tool and i am getting the required data ie name and price of the product. 我正在使用Web收获工具抓取数据,并获得所需的数据,即产品名称和价格。

here is my config file. 这是我的配置文件。

<include path="functions.xml"/>

<!-- collects all tables for individual products -->
<var-def name="products">    
    <call name="download-multipage-list">
        <call-param name="pageUrl">http://www.amazon.de/s/ref=nb_sb_noss?__mk_de_DE=AMAZON&amp;url=search-alias%3Daps&amp;field-keywords=AT300-103%20TEGRA%203%201GB</call-param>
        <call-param name="nextXPath">//a[@class="pagnNext"]/@href</call-param>
        <call-param name="itemXPath">//div[@class="fstRow prod"]</call-param>
        <call-param name="maxloops">10</call-param>
    </call>
</var-def>

<!-- iterates over all collected products and extract desired data -->            
<file action="write" path="reports/catalog.xml" charset="UTF-8">
    <![CDATA[ <catalog> ]]>
    <loop item="item" index="i">
        <list><var name="products"/></list>
        <body>
            <xquery>
                <xq-param name="item" type="node()"><var name="item"/></xq-param>
                <xq-expression><![CDATA[
                        declare variable $item as node() external;

                        let $name := data($item//*[@class='lrg bold'])
                        let $price := data($item//*[@class='bld lrg red'])
                            return
                                <product>
                                    <name>{normalize-space($name)}</name>
                                    <price>{normalize-space($price)}</price>
                                </product>
                ]]></xq-expression>
            </xquery>
        </body>
    </loop>
    <![CDATA[ </catalog> ]]>
</file>

now i am trying to move this name and price information to the mysql database table which contains two columns name and price. 现在,我正在尝试将此名称和价格信息移动到包含两列名称和价格的mysql数据库表中。 i got the information that we have to use database tag. 我得到了我们必须使用数据库标记的信息。 but not getting information how to use that. 但没有获得有关如何使用它的信息。

could you please assist me how can configure that in my config file. 您能帮我怎样在我的配置文件中进行配置吗?

Thanks in advance. 提前致谢。

  • Sahiti 沙希提岛

请访问thorugh web-harvest.sourceforge.net/manual.php#database并尝试按给定的方式实施。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM