The source code is:
<code><a class="figure figure-180236 " data-qidanadd-albumid="543438400" data-qidanadd-episode="0" data-qidanadd-channelid="1" data-qidanadd-tvid="543438400" data-qidanadd-vip="0" data-widget-qidanadd="qidanadd" data-widget-block="block" data-block-type="qs1404043" data-searchpingback-elem="link" data-searchpingback-param="ptype=1-1" href="http://www.iqiyi.com/v_19rr9g9wks.html?fc=87451bff3f7d2f4a#vfrm=2-3-0-1" data-playsrc-linktype="play" data-playsrc-elem="pic" data-pb="rtgt=iqiyi&p2=9000" target="_blank"></code>
The collection php code is:
<code>preg_match("#<a class=\"figure figure-180236 \" data-qidanadd-albumid=\"543438400\" data-qidanadd-episode=\"0\" data-qidanadd-channelid=\"1\" data-qidanadd-tvid=\"543438400\" data-qidanadd-vip=\"0\" data-widget-qidanadd=\"qidanadd\" data-widget-block=\"block\" data-block-type=\"qs1404043\" data-searchpingback-elem=\"link\" data-searchpingback-param=\"ptype=1-1\" href=\"(.*?)\" data-playsrc-linktype=\"play\" data-playsrc-elem=\"pic\" data-pb=\"rtgt=iqiyi&p2=9000\" target=\"_blank\">#",$content,$array);</code>
But the information cannot be collected in this case? Solve
The source code is:
<code><a class="figure figure-180236 " data-qidanadd-albumid="543438400" data-qidanadd-episode="0" data-qidanadd-channelid="1" data-qidanadd-tvid="543438400" data-qidanadd-vip="0" data-widget-qidanadd="qidanadd" data-widget-block="block" data-block-type="qs1404043" data-searchpingback-elem="link" data-searchpingback-param="ptype=1-1" href="http://www.iqiyi.com/v_19rr9g9wks.html?fc=87451bff3f7d2f4a#vfrm=2-3-0-1" data-playsrc-linktype="play" data-playsrc-elem="pic" data-pb="rtgt=iqiyi&p2=9000" target="_blank"></code>
The collection php code is:
<code>preg_match("#<a class=\"figure figure-180236 \" data-qidanadd-albumid=\"543438400\" data-qidanadd-episode=\"0\" data-qidanadd-channelid=\"1\" data-qidanadd-tvid=\"543438400\" data-qidanadd-vip=\"0\" data-widget-qidanadd=\"qidanadd\" data-widget-block=\"block\" data-block-type=\"qs1404043\" data-searchpingback-elem=\"link\" data-searchpingback-param=\"ptype=1-1\" href=\"(.*?)\" data-playsrc-linktype=\"play\" data-playsrc-elem=\"pic\" data-pb=\"rtgt=iqiyi&p2=9000\" target=\"_blank\">#",$content,$array);</code>
But the information cannot be collected in this case? Solve
Please study PHP's regular expression mode carefully. There is an m in it which means multi-line matching can meet your needs, http://php.net/manual/en/refe....
It is recommended to use DiDom for html parsing
Similar to jquery’s dom selection
In the final analysis, you just want to get the href link address of the hyperlink, right? You have written too many regular expressions. The more you write, the harder it is to match. In addition, multi-line matching has special pattern matching characters as mentioned above. I Generally used is s