php正则抓取网站

通过crul抓取到网站之后,通过 preg_match(单一数据) preg_match_all(重复数据,如ul内的li内容或者多个格式一样的控件)来截取自己想要的部分


正则归纳

表示包含所有元素  .*?

空格 \s

图片 "/(href|src)=([\"|']?)([^\"'>]+.(jpg|JPG|jpeg|JPEG|gif|GIF|png|PNG))/i"

a标签 '/<a href=\"(.*?)\".*?>(.*?)<\/a>/i'

preg_match('/<div\sclass="content_list">.*?<\/div>/s',$html,$divList);

猜你喜欢

转载自www.cnblogs.com/slothful/p/12340945.html
今日推荐