Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function parseAd() {
- $bolha = file_get_contents("https://www.bolha.com/index.php?ctl=search_ads&keywords=Canon+60D&sort=new");
- $first_date = true;
- $date_tmp = "";
- $url_string = "";
- while ($pos = strpos($bolha, "EntityList-item EntityList-item--Regular")) {
- $bolha = substr($bolha, $pos, -1);
- $pos = strpos($bolha, 'class="link" href="');
- $bolha = substr($bolha, $pos, -1);
- $pos2 = strpos($bolha, '>');
- $url = substr($bolha, 19, $pos2 - 20);
- $pos = strpos($bolha, '>');
- $bolha = substr($bolha, $pos + 1, -1);
- $pos2 = strpos($bolha, '</a>');
- $title = substr($bolha, 0, $pos2);
- $pos = strpos($bolha, 'pubdate">');
- $bolha = substr($bolha, $pos + 9, -1);
- $pos2 = strpos($bolha, '</time>');
- $end2 = substr($bolha, 0, $pos2 - 1);
- if (true || strpos($title, '60D') !== false) {
- $cnt = DB::table("test")->get();
- foreach ($cnt as $row) {
- $last_known = new DateTime($row->last_date);
- $new_ad = new DateTime($end2);
- if ($new_ad > $last_known) {
- if ($first_date) {
- $dateArray = explode(".", $end2);
- $date_tmp = $dateArray[2] . "-" . $dateArray[1] . '-' . $dateArray[0];
- $first_date = false;
- }
- $url_string .= "https://www.bolha.com" . $url . "<br>";
- } else {
- break 2;
- }
- }
- }
- }
- if (!$first_date) {
- $to = 'oskar.semec1@gmail.com,mitja.usenik@gmail.com';
- $subject = 'Canon 60D';
- $message = "Nov oglas: " . $url_string;
- $headers = 'From: festivaljezikov@lingfest.eu' . "\r\n";// .
- // 'X-Mailer: PHP/' . phpversion();
- $headers .= "MIME-Version: 1.0\r\n";
- $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
- mail($to, $subject, $message, $headers);
- DB::table("test")->update(["last_date" => sprintf("%s", $date_tmp)]);
- }
- $prodajko = file_get_contents("https://www.prodajko.si/iskanje?q=60D");
- $pos = strpos($prodajko, "card-details");
- $prodajko = substr($prodajko, $pos, -1);
- $pos = strpos($prodajko, 'href="');
- $prodajko = substr($prodajko, $pos + 6, -1);
- $pos2 = strpos($prodajko, '">');
- $prodajko = substr($prodajko, 0, $pos2);
- $cnt = DB::table("test")->get();
- foreach ($cnt as $row) {
- $last_known = $row->url;
- if ($prodajko != $last_known || $last_known === NULL) {
- $url = "https://www.prodajko.si" . $prodajko;
- DB::table("test")->update(["url" => sprintf("%s", $prodajko)]);
- $to = 'oskar.semec1@gmail.com,mitja.usenik@gmail.com';
- $subject = 'Canon 60D';
- $message = 'Nov oglas: ' . $url;
- $headers = 'From: festivaljezikov@lingfest.eu' . "\r\n" .
- 'X-Mailer: PHP/' . phpversion();
- mail($to, $subject, $message, $headers);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement