从网站上提取的div中提取数据的高效简便方法

时间:2015-04-01 19:16:48

标签: php html arrays json

你有100个这样的元素* 40个文件= 4000个元素。 我想从每个元素中提取src和href并将其写入数组,以便将其发送到数据库

<a class="market_listing_row_link" href="http://steamcommunity.com/market/listings/730/FAMAS%20%7C%20Colony%20%28Minimal%20Wear%29" id="resultlink_99">
<div class="market_listing_row market_recent_listing_row market_listing_searchresult" id="result_99">
            <img id="result_99_image" src="http://steamcommunity-a.akamaihd.net/economy/image/fWFc82js0fmoRAP-qOIPu5THSWqfSmTELLqcUywGkijVjZYMUrsm1j-9xgEObwgfEh_nvjlWhNzZCveCDfIBj98xqodQ2CZknz59Ne60Iwh0fTvREaFdWco39RrlByIN5M5kXMP49bhWKA3utIrGYLl-M4pJH5PRWaLSNFz5ux1pg_dbeZyPoyvui3i6PnBKBUQvkKsHsA/62fx62f" style="border-color: #D2D2D2;" class="market_listing_item_img" alt="" />      
            <div class="market_listing_right_cell market_listing_their_price">
        <span class="market_table_value">
            Starting at:<br/>
            <span style="color:white">&#36;0.05 USD</span>
        </span>
        <span class="market_arrow_down" style="display: none"></span>
        <span class="market_arrow_up" style="display: none"></span>
    </div>
    <div class="market_listing_right_cell market_listing_num_listings">
        <span class="market_table_value">
            <span class="market_listing_num_listings_qty">6,191</span>
        </span>
    </div>

            <div class="market_listing_item_name_block">
        <span id="result_99_name" class="market_listing_item_name" style="color: #D2D2D2;">FAMAS | Colony (Minimal Wear)</span>
        <br/>
        <span class="market_listing_game_name">Counter-Strike: Global Offensive</span>
    </div>
</div>
</a>

1 个答案:

答案 0 :(得分:0)

您可以尝试使用Simple HTML Dom:http://simplehtmldom.sourceforge.net/

它允许您使用DOM浏览HTML,而不必手动解析所有内容。