php--正则匹配抓取html的相关内容
2018-03-22 11:43
609 查看
$str = <<<s <div class="article-content"> <p><br/></p><section style="background-color: rgb(255, 255, 255); box-sizing: border-box;"><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box;"><section class="" style="position: static; box-sizing: border-box;"><section class="" style="box-sizing: border-box;"><p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box; line-height: 2em; text-indent: 2em;"><span style="font-size: 16px;">据消息,行业大咖林鵬先生、姜殿革先生两位股东现已正式加盟广东中造动力智能设备有限公司。林鵬先生出任中造动力CEO,姜殿革先生出任首席项目总监。中造动力全体同仁为家居行业智能工厂奋斗不息!</span></p><p style="margin-top: 0px; margin-bottom: 0px; padding: 0px; box-sizing: border-box; line-height: 2em; text-indent: 2em;"><span style="font-size: 16px;"><br/></span></p></section></section></section><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box; text-align: center;"><section class="" style="max-width: 100%; vertical-align: middle; display: inline-block; overflow: hidden !important; box-sizing: border-box;"><img src="http://img.xiumi.us/xmi/ua/wCNv/i/4ee0d1eb16c85afa3ac065d83a85e935-sz_3046064.jpg?x-oss-process=style/xm"/></section><p><br/></p></section><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box; text-align: center;"><section class="" style="max-width: 100%; vertical-align: middle; display: inline-block; overflow: hidden !important; box-sizing: border-box;"><img src="http://img.xiumi.us/xmi/ua/wCNv/i/a7098c8e1e408d527455508661b3c26e-sz_3944473.jpg?x-oss-process=style/xm"/></section><p><br/></p></section><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box; text-align: center;"><section class="" style="max-width: 100%; vertical-align: middle; display: inline-block; overflow: hidden !important; box-sizing: border-box;"><img src="http://img.xiumi.us/xmi/ua/wCNv/i/b0e11fb0e0fdbf255589ad9ab2cbe153-sz_3411415.jpg?x-oss-process=style/xm"/></section><p>▲曾总与林鵬先生合照</p><p><br/></p></section><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box; text-align: center;"><section class="" style="max-width: 100%; vertical-align: middle; display: inline-block; overflow: hidden !important; box-sizing: border-box;"><img src="http://img.xiumi.us/xmi/ua/wCNv/i/63960f364ce08383c3160de9b9a32725-sz_3521386.jpg?x-oss-process=style/xm"/></section><p>▲曾总与姜殿革先生合照</p><p><br/></p></section><section class="Powered-by-XIUMI V5" style="position: static; box-sizing: border-box; text-align: center;"><section class="" style="max-width: 100%; vertical-align: middle; display: inline-block; overflow: hidden !important; box-sizing: border-box;"><img src="http://img.xiumi.us/xmi/ua/wCNv/i/9900295260e61eaa3b3ac953f40d8858-sz_1514155.jpg?x-oss-process=style/xm"/></section><p><br/></p></section></section><p><br/></p><p style="text-align: center; line-height: 2em;"><span style="font-size: 16px;">中造动力联系方式</span></p><p style="text-align: center; line-height: 2em;"><span style="font-size: 16px;">固话:0757-23660927</span></p><p style="text-align: center; line-height: 2em;"><span style="font-size: 16px; text-indent: 32px; background-color: rgb(255, 255, 255);">首席项目总监姜殿革先生:18616510086</span></p><p style="text-align: center; line-height: 2em;"><span style="text-indent: 32px; background-color: rgb(255, 255, 255); font-size: 16px;">销售经理刘青松先生:18188721615</span></p><p><br/></p> </div> <div class="article-praise"> <a href="javascript:void(0)" id="read_collection" data-id="11107"><i class="fa fa-heart-o " aria-hidden="true"></i> <span></span> </a> <a href="javascript:void(0)" id="read_praise" data-id="11107"><i class="fa fa-thumbs-o-up " aria-hidden="true"></i> <span>9</span> </a> </div> <div class="articles-hot-recommend"> <div class="header-box"> <div class="box-header"> <h3>推荐阅读</h3> </div> </div> <div class="box-body"> <ul class="articles-list"> <li> <a href="/articles/11107"> <img width="262" height="192" src="https://assets.jxcat.com/expertArticles/2018/wlceym98x.png?x-oss-process=image/resize,m_fill,w_262,h_192,color_FFFFFF" alt="Resize,m fill,w 262,h 192,color ffffff" /> <p class="bg-text"></p> <p class="article-title">行业大咖加盟中造动力,群英助力企业发展</p> </a> </li> <li> <a href="/articles/11077"> <img width="262" height="192" src="https://assets.jxcat.com/expertArticles/2018/3yacvkwbu.jpg?x-oss-process=image/resize,m_fill,w_262,h_192,color_FFFFFF" alt="Resize,m fill,w 262,h 192,color ffffff" /> <p class="bg-text"></p> <p class="article-title">泰国、巴基斯坦、印尼、青岛家协莅临伦教参观考察,共同开展多边贸易</p> </a> </li> <li> <a href="/articles/11025"> <img width="262" height="192" src="https://assets.jxcat.com/articles/2018/ljkdavgrl.jpg?x-oss-process=image/resize,m_fill,w_262,h_192,color_FFFFFF" alt="Resize,m fill,w 262,h 192,color ffffff" /> <p class="bg-text"></p> <p class="article-title">家居新零售正在进行的四大探索</p> </a> </li> </ul> </div> </div> <div class="product-commits article-comments" id="article_comments"> <div class="commit-form"> <div class="commit-title"><h3>说点什么</h3></div> <div class="login-form"> <div class="form-box"> <form data-abide="true" novalidate="novalidate" class="simple_form session" action="/login" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="✓" /><input type="hidden" name="authenticity_token" value="/90DGW7jSEjVwRWMzEAnrkFGqtCQl909u7Ons30WLHperZtZw6evN3Qhs1E8i5douY3xOdcKdbMrDTEhy49Vmg==" /> <ul> <li><div class="form-item form-item-hr"><div class="form-label-hr"><label class="text-right middle" for="session_login"><i class="fa fa-user " aria-hidden="true"></i></label></div><div class="form-input-hr"><input required="required" aria-required="true" placeholder="用户名" type="text" name="session[login]" id="session_login" /></div><div class="checkbox-input"></div></div></li> <li><div class="form-item form-item-hr"><div class="form-label-hr"><label class="text-right middle" for="session_password"><i class="fa fa-unlock-alt " aria-hidden="true"></i></label></div><div class="form-input-hr"><input required="required" aria-required="true" placeholder="密码" type="password" name="session[password]" id="session_password" /></div><div class="checkbox-input"></div></div></li> <li class="form-action"><input type="submit" name="commit" value="登录" class="button submit-button" /></li> </ul> </form> </div> <div class="register-form oauth-login-section"> <div class="oauth-login-entries"> <a href="/oauth/wechat" data-url="/oauth/wechat" class="button gray wechat-login"> 微信登录 </a> <a class="button gray submit-button" href="/register">注册</a> </div> </div> </div> s; $a = '<img class="ywxk" src="/client/images/home/ywxk.png"></img>'; $pattern = '/<img(.+?)src=[\'"](.+?)[\'"](.+?)>/ius'; pr 4000 eg_match_all($pattern, $str, $match); print_r($match);die;直接贴代码吧,(.+?)主要是用来匹配你所想要的信息
相关文章推荐
- php正则表达式,在抓取内容进行匹配的时候表现不稳定
- php正则匹配html中的带class的div,选取其中的内容
- php正则匹配html中带class的div并选取其中内容的方法
- php正则匹配html中带class的div并选取其中内容的方法
- PHP 抓取html页面内容 函数
- PHP 正则表达式抓取网页内容。
- PHP爬虫抓取网页内容 (simple_html_dom.php)
- 正则表达式相关:正则表达式处理html内容
- PHP正则删除html代码中a标签并保留标签内容的方法[原创]_php技巧_脚本之家
- 正则表达式相关:正则表达式处理html内容
- python爬虫主要就是五个模块:爬虫启动入口模块,URL管理器存放已经爬虫的URL和待爬虫URL列表,html下载器,html解析器,html输出器 同时可以掌握到urllib2的使用、bs4(BeautifulSoup)页面解析器、re正则表达式、urlparse、python基础知识回顾(set集合操作)等相关内容。
- php抓取网站内容,获取通达OA官网最新用户,判断页面是否能访问,php正则
- PHP 正则表达式,反向引用(获取匹配的字符串内容)
- PHP正则表达式匹配嵌套HTML标签的方法和技巧
- PHP使用DomDocument抓取HTML内容
- java正则匹配html片段,并取得标签中的内容
- 使用Java正则表达式匹配、替换HTML内容
- 正则表达式,对html内容匹配分组更改(替换/调换)内容
- PHP 正则匹配 HTML 标签