웹페이지 소스 코드의 모든 <a> 태그를 가로채서 배열을 형성하는 PHP 메소드
$url = "http://www.texnet.com.cn/product"; $result = file_get_contents($url); $str = intercept_str($result, '粘上你要开始截取的字符串比如:<p class="productsearch">', '粘上结束时刻的字符串比如:<p class="greenblock1">', 1); //需要先去除所有的换行符、制表符、回车等等,html源文件由于上述符号的存在会造成无法匹配。 $hre = preg_replace("/[\t\n\r]+/","",$str); $reg='/<a .*?>.*?<\/a>/';//这个正则可以自己发挥,博主只是随便放了个匹配<a>标签的 preg_match_all($reg,$hre,$aarray);
//然后就可以打印了呀
dump($aarray);
결과를 직접 보세요:
array(1) { [0] => array(96) { [0] => string(195) "<a href="http://jinxiang.cn.texnet.com.cn" title="桐乡市锦翔纺织有限公司" target="_blank" class="L14 bigblue2"> <font color='#FF0000'>桐乡市</font>锦翔纺织有限公司 </a>" [1] => string(115) "<a href="http://jinxiang.cn.texnet.com.cn/pdetail--840799.html" title="绢丝 " target="_blank" > 绢丝 </a>" [2] => string(113) "<a href="http://jinxiang.cn.texnet.com.cn/pdetail--840798.html" title="绢丝" target="_blank" > 绢丝 </a>" [3] => string(131) "<a href="http://jinxiang.cn.texnet.com.cn/pdetail--840802.html" title="羊毛混纺纱" target="_blank" > 羊毛混纺纱 </a>" [4] => string(131) "<a href="http://jinxiang.cn.texnet.com.cn/pdetail--840800.html" title="绢丝混纺纱" target="_blank" > 绢丝混纺纱 </a>" [5] => string(119) "<a href="http://jinxiang.cn.texnet.com.cn/pdetail--840801.html" title="毛腈纱" target="_blank" > 毛腈纱 </a>" [6] => string(122) "<a href="http://jinxiang.cn.texnet.com.cn" target="_blank" class="green L130 english">http://jinxiang.cn.texnet.com.cn</a>" [7] => string(130) "<a target="_blank" href="/enquiry/?t=company&id=2056"><img src="/images/enquire.gif" style="cursor:pointor" align="absbottom"></a>" [8] => string(205) "<a href="http://zjhtfs.cn.texnet.com.cn" title="桐乡市海通毛绒服饰有限公司" target="_blank" class="L14 bigblue2"> <font color='#FF0000'>桐乡市</font>海通毛绒服饰有限公司 </a>" [9] => string(111) "<a href="http://zjhtfs.cn.texnet.com.cn/pdetail--939047.html" title="粗纱" target="_blank" > 粗纱 </a>" [10] => string(117) "<a href="http://zjhtfs.cn.texnet.com.cn/pdetail--939048.html" title="粗纺纱" target="_blank" > 粗纺纱 </a>" [11] => string(135) "<a href="http://zjhtfs.cn.texnet.com.cn/pdetail--939033.html" title="粗纺羊仔纱线" target="_blank" > 粗纺羊仔纱线 </a>" [12] => string(117) "<a href="http://zjhtfs.cn.texnet.com.cn/pdetail--939043.html" title="丝羊绒" target="_blank" > 丝羊绒 </a>" [13] => string(117) "<a href="http://zjhtfs.cn.texnet.com.cn/pdetail--939046.html" title="羊绒纱" target="_blank" > 羊绒纱 </a>" [14] => string(118) "<a href="http://zjhtfs.cn.texnet.com.cn" target="_blank" class="green L130 english">http://zjhtfs.cn.texnet.com.cn</a>" [15] => string(129) "<a target="_blank" href="/enquiry/?t=company&id=768"><img src="/images/enquire.gif" style="cursor:pointor" align="absbottom"></a>" [16] => string(193) "<a href="http://xtknit.cn.texnet.com.cn" title="桐乡市新拓针织有限公司" target="_blank" class="L14 bigblue2"> <font color='#FF0000'>桐乡市</font>新拓针织有限公司 </a>" [17] => string(117) "<a href="http://xtknit.cn.texnet.com.cn/pdetail--750913.html" title="卫衣布" target="_blank" > 卫衣布 </a>" [18] => string(117) "<a href="http://xtknit.cn.texnet.com.cn/pdetail--750931.html" title="烂花布" target="_blank" > 烂花布 </a>" [19] => string(117) "<a href="http://xtknit.cn.texnet.com.cn/pdetail--750927.html" title="烫金布" target="_blank" > 烫金布 </a>" [20] => string(123) "<a href="http://xtknit.cn.texnet.com.cn/pdetail--750907.html" title="彩条汗布" target="_blank" > 彩条汗布 </a>" [21] => string(111) "<a href="http://xtknit.cn.texnet.com.cn/pdetail--750908.html" title="汗布" target="_blank" > 汗布 </a>" [22] => string(118) "<a href="http://xtknit.cn.texnet.com.cn" target="_blank" class="green L130 english">http://xtknit.cn.texnet.com.cn</a>" [23] => string(129) "<a target="_blank" href="/enquiry/?t=company&id=828"><img src="/images/enquire.gif" style="cursor:pointor" align="absbottom"></a>" [24] => string(193) "<a href="http://zjyuxi.cn.texnet.com.cn" title="桐乡市玉溪针织有限公司" target="_blank" class="L14 bigblue2"> <font color='#FF0000'>桐乡市</font>玉溪针织有限公司 </a>" [25] => string(117) "<a href="http://zjyuxi.cn.texnet.com.cn/pdetail--691497.html" title="印花布" target="_blank" > 印花布 </a>" [26] => string(135) "<a href="http://zjyuxi.cn.texnet.com.cn/pdetail--691378.html" title="人棉氨纶汗布" target="_blank" > 人棉氨纶汗布 </a>" [27] => string(111) "<a href="http://zjyuxi.cn.texnet.com.cn/pdetail--691383.html" title="汗布" target="_blank" > 汗布 </a>" [28] => string(141) "<a href="http://zjyuxi.cn.texnet.com.cn/pdetail--691281.html" title="人棉氨纶印花布" target="_blank" > 人棉氨纶印花布 </a>" [29] => string(116) "<a href="http://zjyuxi.cn.texnet.com.cn/pdetail--10418.html" title="罗马布" target="_blank" > 罗马布 </a>" [30] => string(118) "<a href="http://zjyuxi.cn.texnet.com.cn" target="_blank" class="green L130 english">http://zjyuxi.cn.texnet.com.cn</a>" [31] => string(130) "<a target="_blank" href="/enquiry/?t=company&id=1589"><img src="/images/enquire.gif" style="cursor:pointor" align="absbottom"></a>" [32] => string(192) "<a href="http://zhonglisilk.cn.texnet.com.cn" title="桐乡市洲泉众力丝织厂" target="_blank" class="L14 bigblue2"> <font color='#FF0000'>桐乡市</font>洲泉众力丝织厂 </a>" [33] => string(129) "<a href="http://zhonglisilk.cn.texnet.com.cn/pdetail--1013163.html" title="亚麻彩条" target="_blank" > 亚麻彩条 </a>" [34] => string(129) "<a href="http://zhonglisilk.cn.texnet.com.cn/pdetail--1013180.html" title="亚麻素色" target="_blank" > 亚麻素色 </a>" [35] => string(147) "<a href="http://zhonglisilk.cn.texnet.com.cn/pdetail--1013190.html" title="亚麻烫金针织布" target="_blank" > 亚麻烫金针织布 </a>" [36] => string(129) "<a href="http://zhonglisilk.cn.texnet.com.cn/pdetail--1013192.html" title="亚麻印花" target="_blank" > 亚麻印花 </a>" [37] => string(141) "<a href="http://zhonglisilk.cn.texnet.com.cn/pdetail--1013453.html" title="人棉竹节汗布" target="_blank" > 人棉竹节汗布 </a>" [38] => string(128) "<a href="http://zhonglisilk.cn.texnet.com.cn" target="_blank" class="green L130 english">http://zhonglisilk.cn.texnet.com.cn</a>" [39] => string(130) "<a target="_blank" href="/enquiry/?t=company&id=1918"><img src="/images/enquire.gif" style="cursor:pointor" align="absbottom"></a>" [40] => string(207) "<a href="http://zjqinghe.cn.texnet.com.cn" title="桐乡市清瀛家居用品有限公司" target="_blank" class="L14 bigblue2"> <font color='#FF0000'>桐乡市</font>清瀛家居用品有限公司 </a>" [41] => string(112) "<a href="http://zjqinghe.cn.texnet.com.cn/pdetail--45530.html" title="靠垫" target="_blank" > 靠垫 </a>" [42] => string(118) "<a href="http://zjqinghe.cn.texnet.com.cn/pdetail--50861.html" title="三件套" target="_blank" > 三件套 </a>" [43] => string(113) "<a href="http://zjqinghe.cn.texnet.com.cn/pdetail--712086.html" title="被子" target="_blank" > 被子 </a>" [44] => string(113) "<a href="http://zjqinghe.cn.texnet.com.cn/pdetail--712130.html" title="毯子" target="_blank" > 毯子 </a>" [45] => string(113) "<a href="http://zjqinghe.cn.texnet.com.cn/pdetail--712159.html" title="垫子" target="_blank" > 垫子 </a>" [46] => string(122) "<a href="http://zjqinghe.cn.texnet.com.cn" target="_blank" class="green L130 english">http://zjqinghe.cn.texnet.com.cn</a>" [47] => string(130) "<a target="_blank" href="/enquiry/?t=company&id=1930"><img src="/images/enquire.gif" style="cursor:pointor" align="absbottom"></a>" [48] => string(203) "<a href="http://hlzr.cn.texnet.com.cn" title="桐乡市华灵丝绸有限责任公司" target="_blank" class="L14 bigblue2"> <font color='#FF0000'>桐乡市</font>华灵丝绸有限责任公司 </a>" [49] => string(110) "<a href="http://hlzr.cn.texnet.com.cn/pdetail--1121956.html" title="印花" target="_blank" > 印花 </a>" [50] => string(122) "<a href="http://hlzr.cn.texnet.com.cn/pdetail--1121947.html" title="长毛植绒" target="_blank" > 长毛植绒 </a>" [51] => string(122) "<a href="http://hlzr.cn.texnet.com.cn/pdetail--1121940.html" title="鞋材面料" target="_blank" > 鞋材面料 </a>" [52] => string(122) "<a href="http://hlzr.cn.texnet.com.cn/pdetail--1121933.html" title="服装面料" target="_blank" > 服装面料 </a>" [53] => string(116) "<a href="http://hlzr.cn.texnet.com.cn/pdetail--1121884.html" title="仿羊绒" target="_blank" > 仿羊绒 </a>" [54] => string(114) "<a href="http://hlzr.cn.texnet.com.cn" target="_blank" class="green L130 english">http://hlzr.cn.texnet.com.cn</a>" [55] => string(130) "<a target="_blank" href="/enquiry/?t=company&id=2190"><img src="/images/enquire.gif" style="cursor:pointor" align="absbottom"></a>" [56] => string(198) "<a href="http://chenhuisilk.cn.texnet.com.cn" title="桐乡市晨晖丝绸有限公司" target="_blank" class="L14 bigblue2"> <font color='#FF0000'>桐乡市</font>晨晖丝绸有限公司 </a>" [57] => string(135) "<a href="http://chenhuisilk.cn.texnet.com.cn/pdetail--1521909.html" title="大提花面料" target="_blank" > 大提花面料 </a>" [58] => string(135) "<a href="http://chenhuisilk.cn.texnet.com.cn/pdetail--1522013.html" title="人丝美丽绸" target="_blank" > 人丝美丽绸 </a>" [59] => string(135) "<a href="http://chenhuisilk.cn.texnet.com.cn/pdetail--1522029.html" title="涤丝斜纹绸" target="_blank" > 涤丝斜纹绸 </a>" [60] => string(129) "<a href="http://chenhuisilk.cn.texnet.com.cn/pdetail--1522061.html" title="装饰里布" target="_blank" > 装饰里布 </a>" [61] => string(122) "<a href="http://chenhuisilk.cn.texnet.com.cn/pdetail--612727.html" title="小提花" target="_blank" > 小提花 </a>" [62] => string(128) "<a href="http://chenhuisilk.cn.texnet.com.cn" target="_blank" class="green L130 english">http://chenhuisilk.cn.texnet.com.cn</a>" [63] => string(130) "<a target="_blank" href="/enquiry/?t=company&id=2434"><img src="/images/enquire.gif" style="cursor:pointor" align="absbottom"></a>" [64] => string(193) "<a href="http://jhknit.cn.texnet.com.cn" title="桐乡市嘉鸿针织有限公司" target="_blank" class="L14 bigblue2"> <font color='#FF0000'>桐乡市</font>嘉鸿针织有限公司 </a>" [65] => string(152) "<a href="http://jhknit.cn.texnet.com.cn/pdetail--41316.html" title="彩条丝光棉珠地网眼" target="_blank" > 彩条丝光棉珠地网眼 </a>" [66] => string(140) "<a href="http://jhknit.cn.texnet.com.cn/pdetail--41315.html" title="烫银纯亚麻汗布" target="_blank" > 烫银纯亚麻汗布 </a>" [67] => string(146) "<a href="http://jhknit.cn.texnet.com.cn/pdetail--41313.html" title="双丝光棉彩条罗纹" target="_blank" > 双丝光棉彩条罗纹 </a>" [68] => string(134) "<a href="http://jhknit.cn.texnet.com.cn/pdetail--41322.html" title="彩条氨纶汗布" target="_blank" > 彩条氨纶汗布 </a>" [69] => string(116) "<a href="http://jhknit.cn.texnet.com.cn/pdetail--41310.html" title="罗马布" target="_blank" > 罗马布 </a>" [70] => string(118) "<a href="http://jhknit.cn.texnet.com.cn" target="_blank" class="green L130 english">http://jhknit.cn.texnet.com.cn</a>" [71] => string(130) "<a target="_blank" href="/enquiry/?t=company&id=8694"><img src="/images/enquire.gif" style="cursor:pointor" align="absbottom"></a>" [72] => string(198) "<a href="http://kangtaisilk.cn.texnet.com.cn" title="桐乡市康泰织造有限公司" target="_blank" class="L14 bigblue2"> <font color='#FF0000'>桐乡市</font>康泰织造有限公司 </a>" [73] => string(122) "<a href="http://kangtaisilk.cn.texnet.com.cn/pdetail--716322.html" title="丝绵绸" target="_blank" > 丝绵绸 </a>" [74] => string(134) "<a href="http://kangtaisilk.cn.texnet.com.cn/pdetail--716326.html" title="色织双宫绸" target="_blank" > 色织双宫绸 </a>" [75] => string(116) "<a href="http://kangtaisilk.cn.texnet.com.cn/pdetail--716324.html" title="真丝" target="_blank" > 真丝 </a>" [76] => string(134) "<a href="http://kangtaisilk.cn.texnet.com.cn/pdetail--716321.html" title="涤丝双宫绸" target="_blank" > 涤丝双宫绸 </a>" [77] => string(134) "<a href="http://kangtaisilk.cn.texnet.com.cn/pdetail--716703.html" title="缎染双宫绸" target="_blank" > 缎染双宫绸 </a>" [78] => string(128) "<a href="http://kangtaisilk.cn.texnet.com.cn" target="_blank" class="green L130 english">http://kangtaisilk.cn.texnet.com.cn</a>" [79] => string(131) "<a target="_blank" href="/enquiry/?t=company&id=15390"><img src="/images/enquire.gif" style="cursor:pointor" align="absbottom"></a>" [80] => string(205) "<a href="http://bysilk.cn.texnet.com.cn" title="桐乡市博阳丝绸织造有限公司" target="_blank" class="L14 bigblue2"> <font color='#FF0000'>桐乡市</font>博阳丝绸织造有限公司 </a>" [81] => string(111) "<a href="http://bysilk.cn.texnet.com.cn/pdetail--844020.html" title="丝麻" target="_blank" > 丝麻 </a>" [82] => string(111) "<a href="http://bysilk.cn.texnet.com.cn/pdetail--843991.html" title="围巾" target="_blank" > 围巾 </a>" [83] => string(123) "<a href="http://bysilk.cn.texnet.com.cn/pdetail--843992.html" title="羊绒围巾" target="_blank" > 羊绒围巾 </a>" [84] => string(129) "<a href="http://bysilk.cn.texnet.com.cn/pdetail--843993.html" title="丝羊绒围巾" target="_blank" > 丝羊绒围巾 </a>" [85] => string(123) "<a href="http://bysilk.cn.texnet.com.cn/pdetail--843994.html" title="真丝围巾" target="_blank" > 真丝围巾 </a>" [86] => string(118) "<a href="http://bysilk.cn.texnet.com.cn" target="_blank" class="green L130 english">http://bysilk.cn.texnet.com.cn</a>" [87] => string(132) "<a target="_blank" href="/enquiry/?t=company&id=194739"><img src="/images/enquire.gif" style="cursor:pointor" align="absbottom"></a>" [88] => string(203) "<a href="http://huafangtex.cn.texnet.com.cn" title="桐乡市华方纺织品有限公司" target="_blank" class="L14 bigblue2"> <font color='#FF0000'>桐乡市</font>华方纺织品有限公司 </a>" [89] => string(122) "<a href="http://huafangtex.cn.texnet.com.cn/pdetail--1349605.html" title="毛圈布" target="_blank" > 毛圈布 </a>" [90] => string(122) "<a href="http://huafangtex.cn.texnet.com.cn/pdetail--1349676.html" title="双面布" target="_blank" > 双面布 </a>" [91] => string(116) "<a href="http://huafangtex.cn.texnet.com.cn/pdetail--1349970.html" title="汗布" target="_blank" > 汗布 </a>" [92] => string(128) "<a href="http://huafangtex.cn.texnet.com.cn/pdetail--1350037.html" title="人棉汗布" target="_blank" > 人棉汗布 </a>" [93] => string(140) "<a href="http://huafangtex.cn.texnet.com.cn/pdetail--1349631.html" title="全棉竹节毛圈" target="_blank" > 全棉竹节毛圈 </a>" [94] => string(126) "<a href="http://huafangtex.cn.texnet.com.cn" target="_blank" class="green L130 english">http://huafangtex.cn.texnet.com.cn</a>" [95] => string(132) "<a target="_blank" href="/enquiry/?t=company&id=236133"><img src="/images/enquire.gif" style="cursor:pointor" align="absbottom"></a>" } }
매우 단순하고 매우 폭력적이며 매우 직접적이지 않나요?
위 내용은 웹페이지 소스 코드의 모든 <a> 태그를 가로채서 배열을 형성하는 PHP 메소드의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











PHP 8.4는 상당한 양의 기능 중단 및 제거를 통해 몇 가지 새로운 기능, 보안 개선 및 성능 개선을 제공합니다. 이 가이드에서는 Ubuntu, Debian 또는 해당 파생 제품에서 PHP 8.4를 설치하거나 PHP 8.4로 업그레이드하는 방법을 설명합니다.

VS Code라고도 알려진 Visual Studio Code는 모든 주요 운영 체제에서 사용할 수 있는 무료 소스 코드 편집기 또는 통합 개발 환경(IDE)입니다. 다양한 프로그래밍 언어에 대한 대규모 확장 모음을 통해 VS Code는

숙련된 PHP 개발자라면 이미 그런 일을 해왔다는 느낌을 받을 것입니다. 귀하는 상당한 수의 애플리케이션을 개발하고, 수백만 줄의 코드를 디버깅하고, 여러 스크립트를 수정하여 작업을 수행했습니다.

이 튜토리얼은 PHP를 사용하여 XML 문서를 효율적으로 처리하는 방법을 보여줍니다. XML (Extensible Markup Language)은 인간의 가독성과 기계 구문 분석을 위해 설계된 다목적 텍스트 기반 마크 업 언어입니다. 일반적으로 데이터 저장 AN에 사용됩니다

JWT는 주로 신분증 인증 및 정보 교환을 위해 당사자간에 정보를 안전하게 전송하는 데 사용되는 JSON을 기반으로 한 개방형 표준입니다. 1. JWT는 헤더, 페이로드 및 서명의 세 부분으로 구성됩니다. 2. JWT의 작업 원칙에는 세 가지 단계가 포함됩니다. JWT 생성, JWT 확인 및 Parsing Payload. 3. PHP에서 인증에 JWT를 사용하면 JWT를 생성하고 확인할 수 있으며 사용자 역할 및 권한 정보가 고급 사용에 포함될 수 있습니다. 4. 일반적인 오류에는 서명 검증 실패, 토큰 만료 및 대형 페이로드가 포함됩니다. 디버깅 기술에는 디버깅 도구 및 로깅 사용이 포함됩니다. 5. 성능 최적화 및 모범 사례에는 적절한 시그니처 알고리즘 사용, 타당성 기간 설정 합리적,

문자열은 문자, 숫자 및 기호를 포함하여 일련의 문자입니다. 이 튜토리얼은 다른 방법을 사용하여 PHP의 주어진 문자열의 모음 수를 계산하는 방법을 배웁니다. 영어의 모음은 A, E, I, O, U이며 대문자 또는 소문자 일 수 있습니다. 모음이란 무엇입니까? 모음은 특정 발음을 나타내는 알파벳 문자입니다. 대문자와 소문자를 포함하여 영어에는 5 개의 모음이 있습니다. a, e, i, o, u 예 1 입력 : String = "Tutorialspoint" 출력 : 6 설명하다 문자열의 "Tutorialspoint"의 모음은 u, o, i, a, o, i입니다. 총 6 개의 위안이 있습니다

정적 바인딩 (정적 : :)는 PHP에서 늦은 정적 바인딩 (LSB)을 구현하여 클래스를 정의하는 대신 정적 컨텍스트에서 호출 클래스를 참조 할 수 있습니다. 1) 구문 분석 프로세스는 런타임에 수행됩니다. 2) 상속 관계에서 통화 클래스를 찾아보십시오. 3) 성능 오버 헤드를 가져올 수 있습니다.

PHP의 마법 방법은 무엇입니까? PHP의 마법 방법은 다음과 같습니다. 1. \ _ \ _ Construct, 객체를 초기화하는 데 사용됩니다. 2. \ _ \ _ 파괴, 자원을 정리하는 데 사용됩니다. 3. \ _ \ _ 호출, 존재하지 않는 메소드 호출을 처리하십시오. 4. \ _ \ _ get, 동적 속성 액세스를 구현하십시오. 5. \ _ \ _ Set, 동적 속성 설정을 구현하십시오. 이러한 방법은 특정 상황에서 자동으로 호출되어 코드 유연성과 효율성을 향상시킵니다.
