PHP如何采集网页指定标签里面的数据
Jun 23, 2016 pm 01:59 PM PHP采集问题,如何采集源码中ul标签里的数据,并写入本地数据库:
对方网页某一段源码如下:
<ul class="priceTableRows"> <li class="cq"> <span class="w1"><a href="http://www.xxxx.cn/exchange-priceItem-290-1-0.html" title=" 鸡骨草" target="_blank"> 鸡骨草</a></span> <span class="w2"><a href="http://www.xxxx.cn/exchange-prices-290-1-29001.html?t=1" title=" 大叶全草 广西" target="_blank"> 大叶全草 广西</a></span> <span class="w9">亳州</span> <span class="w3">17.00</span> <span class="w4">平</span> <span class="w5"><em class="up">126.67%</em></span> <span class="w6"><em class="up">126.67%</em></span> <span class="w7"><em class="up">286.36%</em></span> <span class="w8"><a href="http://www.xxxx.cn/exchange-prices-290-1-29001.html?t=1" title=" 鸡骨草" target="_blank"><img src="/static/imghw/default1.png" data-src="http://img.zyctd.com/MarketCondition/icon_chart.gif" class="lazy" / alt="PHP如何采集网页指定标签里面的数据" ></a></span> </li> <li> <span class="w1"><a href="http://www.xxxx.cn/exchange-priceItem-290-1-0.html" title=" 鸡骨草" target="_blank"> 鸡骨草</a></span> <span class="w2"><a href="http://www.xxxx.cn/exchange-prices-290-1-29002.html?t=1" title=" 小叶全草 广西" target="_blank"> 小叶全草 广西</a></span> <span class="w9">亳州</span> <span class="w3"> 20.00 </span> <span class="w4">平</span> <span class="w5"><em class="up">122.22%</em></span> <span class="w6"><em class="up">122.22%</em></span> <span class="w7"><em class="up">198.51%</em></span> <span class="w8"><a href="http://www.xxxx.cn/exchange-prices-290-1-29002.html?t=1" title=" 鸡骨草" target="_blank"><img src="/static/imghw/default1.png" data-src="http://img.zyctd.com/MarketCondition/icon_chart.gif" class="lazy" / alt="PHP如何采集网页指定标签里面的数据" ></a></span> </li> <li class="cq"> <span class="w1"><a href="http://www.xxxx.cn/exchange-priceItem-290-1-0.html" title=" 鸡骨草" target="_blank"> 鸡骨草</a></span> <span class="w2"><a href="http://www.xxxx.cn/exchange-prices-290-1-29003.html?t=1" title=" 大叶光杆 广西" target="_blank"> 大叶光杆 广西</a></span> <span class="w9">亳州</span> <span class="w3">20.00</span> <span class="w4">平</span> <span class="w5"><em class="up">42.86%</em></span> <span class="w6"><em class="up">42.86%</em></span> <span class="w7"><em class="up">127.27%</em></span> <span class="w8"><a href="http://www.xxxx.cn/exchange-prices-290-1-29003.html?t=1" title=" 鸡骨草" target="_blank"><img src="/static/imghw/default1.png" data-src="http://img.zyctd.com/MarketCondition/icon_chart.gif" class="lazy" / alt="PHP如何采集网页指定标签里面的数据" ></a></span> </li> ..........</ul>
我需要采集 所有
请问各位大侠,如何写采集代码呢?
回复讨论(解决方案)
采集的话用file_get_contents()/curl 都可以实现,先采集过来再截取你想要的内容。
如何写采集代码可以看这里:http://www.jb51.net/tools/zhengze.html
可以用正则表达式来匹配
火车头工具……
火车头工具……
火车头能实现这种效果????????
用正则匹配吧

Heißer Artikel

Hot-Tools-Tags

Heißer Artikel

Heiße Artikel -Tags

Notepad++7.3.1
Einfach zu bedienender und kostenloser Code-Editor

SublimeText3 chinesische Version
Chinesische Version, sehr einfach zu bedienen

Senden Sie Studio 13.0.1
Leistungsstarke integrierte PHP-Entwicklungsumgebung

Dreamweaver CS6
Visuelle Webentwicklungstools

SublimeText3 Mac-Version
Codebearbeitungssoftware auf Gottesniveau (SublimeText3)

Heiße Themen

11 beste PHP -URL -Shortener -Skripte (kostenlos und Premium)

Arbeiten mit Flash -Sitzungsdaten in Laravel

Erstellen Sie eine React -App mit einem Laravel -Back -Ende: Teil 2, reagieren

Vereinfachte HTTP -Reaktion verspottet in Laravel -Tests

Curl in PHP: So verwenden Sie die PHP -Curl -Erweiterung in REST -APIs

12 Beste PHP -Chat -Skripte auf Codecanyon

Ankündigung von 2025 PHP Situation Survey
