php - Using preg_match_all to extract all image links on a webpage -
I'm having some difficulty with this pattern - "/([az-_0-9/\:.]* Of course, my regex is a little weak within. (Jpg | jpeg | png)) / i "- preg_match_all function, so I suspect there is something wrong with it.
What do I have at the moment -
preg_match_all ("/ ([az \ -_0- 9 \ / \: \.] *. (Jpg | jpeg | Png) / i ", $ raw, $ match)
From this page -
There is a bunch of images on the page that is not being dragged , All I am getting is ($ 0) of the matching array - [balance] is repeated) data in a different format.
array (8) {[0] => ; String (77) "http://media.topshop.com/wcsstore/TopShop/images/catalog/05K01FBLC_normal.jpg" [1] = & gt; String (143) "/wcsstore/ConsumerDirectStorefrontAssetStore/images/colors/color7/cms/pages/static/static-0000067510/images/tact-wk24-LFWshipping_UK-ROW-EU.jpg" [2] = & gt; String (76) "http://media.topshop.com/wcsstore/TopShop/images/catalog/05K01FBLC_large.jpg" [3] = & gt; String (77) "http://media.topshop.com/wcsstore/TopShop/images/catalog/05K01FBLC_normal.jpg" [4] = & gt; String (40) "//assets.pinterest.com/images/PinExt.png" [5] = & gt; String (41) "http://platform.tumblr.com/v1/share_4.png" [6] = & gt; String (163) "http://media.topshop.com/wcsstore/ConsumerDirectStorefrontAssetStore/images/colors/color7/cms/pages/static/static-0000067528/images/PDP-wk24-LFWshipping_ROW-EU.jpg" [7] = & Gt; String (119) "/wcsstore/ConsumerDirectStorefrontAssetStore/images/colors/color7/cms/pages/static/static-0000008560/images/onthego.png"}
If someone can give me one Why is it not dragging every image on the page due to a bit of information about it and these are just 8 pictures?
Is there something in the form of regular expression that I get?
I can not find this JPG link - though it is on the page
Any help will be most appreciated.
Greg
I used it and found 25 images from the page, like Mellit Put in the comments he got from you.
preg_match_all ('/ ([- a-z0-9_ \ /:.] + \. (Jpg | jpeg | png)) / i', $ crude, $ match); Print "& lt; east & gt;"; Print_r ($ matches [0]); Print "& lt; / pre & gt;";
There is only to mention things that you do not need to avoid all the characters in the character class - only the forward slash because it is the delimiter you are using. Also, after you type your character class, you should use the plus sign +
instead of the asterisk *
after typing at least one letter in the name of your image.
Comments
Post a Comment