


Curl write request to steal Jinshi.com homepage data, with thinkphp source code package attached
After playing with curl, I found that php regularization is really important, but unfortunately I am very bad at it. I took three fields on the web page and wrote a demo. Copy the code posted below and run it directly. In fact, it is an idea of using other people's data to make your own API. <?php <br />
function getwebcontent($url){ <br>
$ch = curl_init(); <br>
curl_setopt($ch, CURLOPT_URL, $url); <br>
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); <br>
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); <br>
$contents = trim(curl_exec($ch)); <br>
curl_close($ch); <br>
Return $contents; <br>
} <br>
function DeleteHtml($str) { <br>
$str = trim($str); <br>
$str = str_replace("t","",$str); <br>
$str = str_replace("rn","",$str); <br>
$str = str_replace("r","",$str); <br>
$str = str_replace("n","",$str); <br>
Return trim($str); <br>
}<br>
set_time_limit(0);<br>
$datas =DeleteHtml(getwebcontent('http://www.jin10.com')); <br>
Preg_match_all('/(d{2}:d{2})/',$datas,$time); /*All corresponding times*/<br>
preg_match_all('/<td>]+?ids*?=s*?"content_d+?">(.+?)</td>/',$datas,$content); /*Corresponding All content*/<br>
Preg_match_all('/"General news"|"Important news"|"General data"|"Important data"/',$datas,$importance); /*The importance of all corresponding news*/<br>
$contents=$content[1]; /*All corresponding contents*/<br>
$times=$time[1]; /*All corresponding times*/<br>
$importances=$importance[0];<br>
<br>
$news=[];<br>
foreach ($contents as $key => $value) {<br>
$t=[<br>
"content"=>$value,<br>
"time"=>$times[$key],<br>
“Importance”=>str_replace('"','',$importances[$key]),<br>
];<br>
array_push($news,$t);<br>
}<br>
var_dump($news);<br>
<br>
?>
109news.rar
( 1.12 MB Download: 7 times )

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Atom editor mac version download
The most popular open source editor

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver Mac version
Visual web development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment
