Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function curl($url) {
- $ch = curl_init(); // Initialising cURL
- curl_setopt($ch, CURLOPT_URL, $url); // Setting cURL's URL option with the $url variable passed into the function
- curl_setopt($ch, CURLOPT_HEADER, false);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // Setting cURL's option to return the webpage data
- //curl_setopt($ch, CURLOPT_SSLVERSION,3);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- $data = curl_exec($ch); // Executing the cURL request and assigning the returned data to the $data variable
- curl_close($ch); // Closing cURL
- return $data; // Returning the data from the function
- }
- function scrape_between($data, $start, $end){
- $data = stristr($data, $start); // Stripping all data from before $start
- $data = substr($data, strlen($start)); // Stripping $start
- $stop = stripos($data, $end); // Getting the position of the $end of the data to scrape
- $data = substr($data, 0, $stop); // Stripping all data from after and including the $end of the data to scrape
- return $data; // Returning the scraped data from the function
- }
- $url = "https://alltop.com/viral/";
- $scraped_website = curl($url);
- $datastart = "post-title" . chr(34) . ">";
- $dataend = "</h2>";
- $content1 = scrape_between($scraped_website,$datastart,$dataend);
- echo $content1;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement