php不会正则的痛
不会正则下载暴漫好痛苦,唯一的正则是网上找的,最后还是用explode来处理了,小弟新人,求大牛改正。 无 ?php/** * 正则表达式匹配需要的图片 * @return ArrayIterator $arr */function pregIMG($str){//$str ='a href="/articles/7442969" target="_blank"i
不会正则下载暴漫好痛苦,唯一的正则是网上找的,最后还是用explode来处理了,小弟新人,求大牛改正。
<?php /** * 正则表达式匹配需要的图片 * @return ArrayIterator $arr */ function pregIMG($str){ //$str ='<a href="/articles/7442969" target="_blank"><img src="/static/imghw/default1.png" data-src="http://www.68idc.cn/help/uploads/allimg/160322/2016161356-0.jpg" class="lazy" alt="没标题" style="max-width:90%" /></a>'; $pattern='/<img src="/static/imghw/default1.png" data-src="http://www.68idc.cn/help/uploads/allimg/160322/2016162634-1.jpg" class="lazy" .+src=\"(.+\.jpg)\"?.+ alt="php不会正则的痛" >/i'; preg_match_all($pattern,$str,$matchs); return $matchs; } /** * 查找某个页面的jpg */ function getIMG($url,$dir){ if (empty($url)) return false; $contents = file_get_contents($url); $data = pregIMG($contents); $jpgs = $data[1]; unset($data); $data = array(); foreach ($jpgs as $k => $v){ $t = explode('/', $v); if ($t[3] == 'large'){ $data[$k] = $v; } } if(!file_exists($dir) || !is_dir($dir)){ mkdir($dir,0777); } $num = 1; foreach ($data as $v){ copy($v, $dir.'/'.time(). rand(10,100).'.jpg'); usleep(1); $num++; } return $num; } function getBaoZou($page=1){ $url = "http://baozoumanhua.com/tucao/fresh/page/".$page."?sv=1395827058"; $dir = "public"; return getIMG($url, $dir); } function getMoreBaoZou($page){ //下载前10页 $num = 0; for ($i = 1;$i < $page; $i++){ $num += getBaoZou($i); } echo '一共下载了'.$num.'张暴走漫画'; } getMoreBaoZou(10);//获取前10页的暴走漫画 ?>


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP is an open source MVC framework. It makes developing, deploying and maintaining applications much easier. CakePHP has a number of libraries to reduce the overload of most common tasks.

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op
