Парсер раздач с трекеров

Парсер раздач с трекеров 1.0.0

Нет прав для скачивания

sergey67

Пользователь
Всем привет! Ребят, столкнулся с такой проблемой, сделал парсер мптор, а у них некоторые данные идут через CloudFlare Email Protection, и их не получается спарсить, т.к. в исходном коде вместо данных вот такая балалайка <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7c2f15110c10193c3049">[email&#160;protected]</a>
Подскажите пожалуйста, можно как-то спарсить эту инфу?
 

sergey67

Пользователь
Удалось отловить скрипт,который прячет инфу

!function(){"use strict";function e(e){try{if("undefined"==typeof console)return;"error"in console?console.error(e):console.log(e)}catch(e){}}function t(e){return d.innerHTML='<a href="'+e.replace(/"/g,"&quot;")+'"></a>',d.childNodes[0].getAttribute("href")||""}function r(e,t){var r=e.substr(t,2);return parseInt(r,16)}function n(n,c){for(var o="",a=r(n,c),i=c+2;i<n.length;i+=2){var l=r(n,i)^a;o+=String.fromCharCode(l)}try{o=decodeURIComponent(escape(o))}catch(u){e(u)}return t(o)}function c(t){for(var r=t.querySelectorAll("a"),c=0;c<r.length;c++)try{var o=r[c],a=o.href.indexOf(l);a>-1&&(o.href="mailto:"+n(o.href,a+l.length))}catch(i){e(i)}}function o(t){for(var r=t.querySelectorAll(u),c=0;c<r.length;c++)try{var o=r[c],a=o.parentNode,i=o.getAttribute(f);if(i){var l=n(i,0),d=document.createTextNode(l);a.replaceChild(d,o)}}catch(h){e(h)}}function a(t){for(var r=t.querySelectorAll("template"),n=0;n<r.length;n++)try{i(r[n].content)}catch(c){e(c)}}function i(t){try{c(t),o(t),a(t)}catch(r){e(r)}}var l="/cdn-cgi/l/email-protection#",u=".__cf_email__",f="data-cfemail",d=document.createElement("div");i(document),function(){var e=document.currentScript||document.scripts[document.scripts.length-1];e.parentNode.removeChild(e)}()}();

Только как из него инфу вытащить?
 

sergey67

Пользователь
Здравствуйте. Подскажите пожалуйста, как сделать проверку на повтор в парсере, чтобы при повторе не записывалось в БД?
 

sergey67

Пользователь
Привет. Помогите пожалуйста реализовать код для парсера, который мог бы картинки забирать и заливать в локальную галерею. Написал парсер на один трекер, и проблема в том, что, у них картинки (постер и скриншоты) локальные, и они запрещены для отображения на других ресурсах

Т.е. после парсинга раздачи, картинки не отображаются
 

sergey67

Пользователь
PHP:
        function torrentwindows($text, $mode = false)
        {


            if ($mode == 'title')
            {
                preg_match_all ("#<h1>([\s\S]*?)</h1>#", $text, $source, PREG_SET_ORDER);
                $text = $source[0][1];
                $text = str_replace(' скачать торрент бесплатно', '', $text);
            }
            elseif ($mode == 'torrent')
            {
                preg_match_all ('#href= \".*?index.php\?do=download&id=([\s\S]*?)\"#', $text, $source, PREG_SET_ORDER);
                $text = $source[0][1];
                //var_dump($source);

            }
            else
            {
                
                $pos = strpos($text, '<br class="clearfix" />');
                $text = substr($text, $pos);
                $pos = strpos($text, '<center><span class="attachment"><center>');
                $text = substr($text, 0, $pos);
                $text = preg_replace("/<br class=\"clearfix\" \/>\n\n/", '', $text);
                /*
                preg_match_all ('/<meta property="og:image" content="([\s\S]*?)">/', $text, $pic, PREG_SET_ORDER);
                $poster = ($pic[0][1]) ? "[img=right]". $pic[0][1] ."[/img]\n\n" : "";
                
                $text = preg_replace('/<\/center><div style="text-align:center;"><!--TBegin.*?--><a href="(.*?)".*?><img src=".*?".*?><\/a><!--TEnd--><\/div>/', "[img=right]$1[/img]\n", $text);
                */
                $text = str_replace('&nbsp;', ' ', $text);
                $text = str_replace('<div', '<span', $text);
                $text = str_replace('</div>', '</span>', $text);
                $text = preg_replace('/<a href="javascript[^<]*?"><img id="image.*?" style="vertical-align: middle;border: none;" alt="" src=".*?" \/><\/a>/', '', $text);
                
                $text = preg_replace_callback(
                "/<span style=\"color:rgb\(([\s\S]*?)\);\">/msi",
                function($matches){
                    foreach($matches as $match)
                     $match = rgb2html($match);
                    {
                        return "<span style=\"color:rgb$match;\">";
                    }
                },
                $text
            );
                $text = preg_replace('/<!--.*?-->/', '', $text);
                $text = preg_replace('/<!--dle_image_begin.*?<img src="(.*?)".*?><!--dle_image_end-->/', '[img]$1[/img]', $text);
                $text = preg_replace('/<span class="masha_index.*?"><\/span>/', '', $text);
                $text = preg_replace("/<span style=\"font-size: 15px;\">[\s\S]*?<a class=\"highslide\" href=\"(.*?)\" target=\"_blank\"><img src=\".*?\" alt=\"\" class=\"fr-dib\"><\/a>/", "[img=right]$1[/img]\n\n", $text);
                
                /*
                $text = preg_replace('/<!--dle_spoiler.*? -->/', '', $text);

                $text = preg_replace('/<!--spoiler[\s\S]*?-->/', '', $text);

                $text = preg_replace('/<div class="v_text">[\s\S]*?<a href=".*?={name}">[\s\S]*?<\/a><\/center>[\s\S]*?<\/center>/', '', $text);

                $text = preg_replace('/<div style="text-align:([\s\S]*?);">([\s\S]*?)<(?=\/)\/div>/', '[align=$1]$2[/align]', $text);
                
                $text = preg_replace('/<a href="(.*?)" rel="highslide" class="highslide"><img src=".*?" alt=\'.*?\' title=\'.*?\'  \/><\/a>/', '[img=right]$1[/img]', $text);
                $text = preg_replace('/<img src="\/uploads\/posts\/([\s\S]*?)\" alt=".*?" title=".*?">/', '[img]https://torrent-windows.net/uploads/posts/$1[/img]', $text);
            */

                $text = preg_replace('/<a href="javascript[^<]*?">([^<]*?)<(?=\/)\/a>/', '$1', $text);

                $text = preg_replace('/<center><a href="https.*?sub2.bubblesmedia.ru.*?"><img src="\/.*?.jpg"><\/a><\/center>/', '', $text);
                $text = preg_replace('/<center><a href=".*?" target="_blank"><span.*?><noindex>.*?<\/noindex><\/span><\/a>.*?<\/center>/', '', $text);

                for ($i=0; $i<=20; $i++)
                {
                $text = preg_replace('/<img src="\/uploads\/posts\/([\s\S]*?)\" style=".*?" alt="">/', '[img]https://torrent-windows.net/uploads/posts/$1[/img]', $text);
                $text = str_replace('<br>', "\n", $text);
                $text = str_replace('<br />', "\n", $text);
                $text = str_replace('<hr>', '[hr]', $text);
                $text = str_replace('<u>', "[u]", $text);
                $text = str_replace('</u>', "[/u]", $text);
                $text = str_replace('<b>', "[b]", $text);
                $text = str_replace('</b>', "[/b]", $text);
                $text = str_replace('<i>', "[i]", $text);
                $text = str_replace('</i>', "[/i]", $text);
                $text = str_replace('<li>', "\n[*]", $text);
                $text = str_replace('</li>', '', $text);
                $text = preg_replace('/<span style="font-size:(.*?)pt;">([\s\S]*?)<(?=\/)\/span>/', '[size=\\1]\\2[/size]', $text);
                $text = preg_replace('/<span style="font-size:(.*?)px;line-height:normal;">([\s\S]*?)<(?=\/)\/span>/', '[size=\\1]\\2[/size]', $text);
                $text = preg_replace('/<img src="([\s\S]*?)" class="fr-fic fr-dii".*?>/', '[img]$1[/img]', $text);
                $text = preg_replace('/<a href="([^<]*?)".*?target="_blank".*?>([^<]*?)<\/a>/', '[url=$1]$2[/url]  ', $text);
                $text = preg_replace('/<a href="([\s\S]*?)".*?target="_blank" rel="noopener external noreferrer">([\s\S]*?)<(?=\/)\/a>/', '[url=$1]$2[/url]', $text);
                $text = preg_replace('/<span style="color:rgb([^<]*?);">([^<]*?)<(?=\/)\/span>/', '[color=$1]$2[/color]', $text);
                $text = preg_replace('/<span style="color:([^<]*?);.*?">([^<]*?)<(?=\/)\/span>/', '[color=$1]$2[/color]', $text);
                $text = preg_replace('/<span style="font-weight:bold;">([^<]*?)<(?=\/)\/span>/', '[b]$1[/b]', $text);
                $text = preg_replace('/<span style="text-align:([^<]*?);display:block;">([\s\S]*?)<(?=\/)\/span>/', "[align=\\1]\n\\2\n[/align]", $text);
                $text = preg_replace('/<span align="([^<]*?)">([^<]*?)<(?=\/)\/span>/', "[align=\\1]\\2[/align]", $text);

                $text = preg_replace('/<span style="text-decoration:underline;">([^<]*?)<(?=\/)\/span>/', '[u]$1[/u]', $text);
                $text = preg_replace('/<span class="title_spoiler">([^<]*?)<(?=\/)\/span><span.*?class="text_spoiler" style="display:none;">([^<]*?)<(?=\/)\/span>/', '[spoiler="$1"]$2[/spoiler]', $text);

                //$text = preg_replace('/<!--spoiler_title-->([\s\S]*?)<!--spoiler_title_end-->.*?<!--spoiler_text-->([\s\S]*?)<!--spoiler_text_end--><(?=\/)\/div>/', "[spoiler=\\1]\n\\2\n[/spoiler]", $text);
                    $text = preg_replace('/http:(.*?)fastpic.ru/', "https:$1fastpic.ru/", $text);
                    $text = preg_replace('/http:(.*?)imageban.ru/', "https:$1imageban.ru/", $text);
                    $text = preg_replace('/http:(.*?)youpic.su/', "https:$1youpic.su/", $text);
                    $text = preg_replace('/http:(.*?)lostpic.net/', "https:$1lostpic.net/", $text);
                    $text = preg_replace('/http:(.*?)*******.host/', "https:$1radikal.host/", $text);
                    $text = str_replace('http://img-fotki.yandex.ru', 'https://img-fotki.yandex.ru', $text);
                }

            if(strlen($text) > 55){
                false;
                }
                else{
                $text = preg_replace('#<br />(.*?):#', "[b]$1:[/b] ", $text);
                $text = preg_replace('#<br>(.*?):#', "[b]$1:[/b] ", $text);
                }
                $text = preg_replace('/<a class="highslide" href="(.*?)" target="_blank"><img src=".*?" alt="" class="fr-dib"><\/a>/', '[th]$1[/th]', $text);
                $text = str_replace('Скачать торрент:', "", $text);
                $text = str_replace('Состав раздачи', "", $text);
                $text = str_replace('Показать / Скрыть текст', "", $text);
                $text = preg_replace('/\[url=.*?multi-up.com.*?\].*?\[\/url\]/', "", $text);
                //$text = str_replace('Версия программы:', "[b]Версия программы:[/b]", $text);
                

                // Убираем пустое пространство
                //$text = preg_replace('#([\r\n])[\s]+#is', "$1", $text);
                $text = strip_tags(html_entity_decode($text));
            }
            
                $text = preg_replace_callback('/<a href=".*?">(.*?)<\/a>/', function ($v)
                {
                    return '[url=https://www.hitrustor.me/tracker.php?' . http_build_query(['nm' => $v[1]]) . ']' . $v[1] . '[/url]';
                },
                $text);
            return $text;
        }
 

zxc

Легенда
PHP:
        function torrentwindows($text, $mode = false)
        {


            if ($mode == 'title')
            {
                preg_match_all ("#<h1>([\s\S]*?)</h1>#", $text, $source, PREG_SET_ORDER);
                $text = $source[0][1];
                $text = str_replace(' скачать торрент бесплатно', '', $text);
            }
            elseif ($mode == 'torrent')
            {
                preg_match_all ('#href= \".*?index.php\?do=download&id=([\s\S]*?)\"#', $text, $source, PREG_SET_ORDER);
                $text = $source[0][1];
                //var_dump($source);

            }
            else
            {
               
                $pos = strpos($text, '<br class="clearfix" />');
                $text = substr($text, $pos);
                $pos = strpos($text, '<center><span class="attachment"><center>');
                $text = substr($text, 0, $pos);
                $text = preg_replace("/<br class=\"clearfix\" \/>\n\n/", '', $text);
                /*
                preg_match_all ('/<meta property="og:image" content="([\s\S]*?)">/', $text, $pic, PREG_SET_ORDER);
                $poster = ($pic[0][1]) ? "[img=right]". $pic[0][1] ."[/img]\n\n" : "";
               
                $text = preg_replace('/<\/center><div style="text-align:center;"><!--TBegin.*?--><a href="(.*?)".*?><img src=".*?".*?><\/a><!--TEnd--><\/div>/', "[img=right]$1[/img]\n", $text);
                */
                $text = str_replace('&nbsp;', ' ', $text);
                $text = str_replace('<div', '<span', $text);
                $text = str_replace('</div>', '</span>', $text);
                $text = preg_replace('/<a href="javascript[^<]*?"><img id="image.*?" style="vertical-align: middle;border: none;" alt="" src=".*?" \/><\/a>/', '', $text);
               
                $text = preg_replace_callback(
                "/<span style=\"color:rgb\(([\s\S]*?)\);\">/msi",
                function($matches){
                    foreach($matches as $match)
                     $match = rgb2html($match);
                    {
                        return "<span style=\"color:rgb$match;\">";
                    }
                },
                $text
            );
                $text = preg_replace('/<!--.*?-->/', '', $text);
                $text = preg_replace('/<!--dle_image_begin.*?<img src="(.*?)".*?><!--dle_image_end-->/', '[img]$1[/img]', $text);
                $text = preg_replace('/<span class="masha_index.*?"><\/span>/', '', $text);
                $text = preg_replace("/<span style=\"font-size: 15px;\">[\s\S]*?<a class=\"highslide\" href=\"(.*?)\" target=\"_blank\"><img src=\".*?\" alt=\"\" class=\"fr-dib\"><\/a>/", "[img=right]$1[/img]\n\n", $text);
               
                /*
                $text = preg_replace('/<!--dle_spoiler.*? -->/', '', $text);

                $text = preg_replace('/<!--spoiler[\s\S]*?-->/', '', $text);

                $text = preg_replace('/<div class="v_text">[\s\S]*?<a href=".*?={name}">[\s\S]*?<\/a><\/center>[\s\S]*?<\/center>/', '', $text);

                $text = preg_replace('/<div style="text-align:([\s\S]*?);">([\s\S]*?)<(?=\/)\/div>/', '[align=$1]$2[/align]', $text);
               
                $text = preg_replace('/<a href="(.*?)" rel="highslide" class="highslide"><img src=".*?" alt=\'.*?\' title=\'.*?\'  \/><\/a>/', '[img=right]$1[/img]', $text);
                $text = preg_replace('/<img src="\/uploads\/posts\/([\s\S]*?)\" alt=".*?" title=".*?">/', '[img]https://torrent-windows.net/uploads/posts/$1[/img]', $text);
            */

                $text = preg_replace('/<a href="javascript[^<]*?">([^<]*?)<(?=\/)\/a>/', '$1', $text);

                $text = preg_replace('/<center><a href="https.*?sub2.bubblesmedia.ru.*?"><img src="\/.*?.jpg"><\/a><\/center>/', '', $text);
                $text = preg_replace('/<center><a href=".*?" target="_blank"><span.*?><noindex>.*?<\/noindex><\/span><\/a>.*?<\/center>/', '', $text);

                for ($i=0; $i<=20; $i++)
                {
                $text = preg_replace('/<img src="\/uploads\/posts\/([\s\S]*?)\" style=".*?" alt="">/', '[img]https://torrent-windows.net/uploads/posts/$1[/img]', $text);
                $text = str_replace('<br>', "\n", $text);
                $text = str_replace('<br />', "\n", $text);
                $text = str_replace('<hr>', '[hr]', $text);
                $text = str_replace('<u>', "[u]", $text);
                $text = str_replace('</u>', "[/u]", $text);
                $text = str_replace('<b>', "[b]", $text);
                $text = str_replace('</b>', "[/b]", $text);
                $text = str_replace('<i>', "[i]", $text);
                $text = str_replace('</i>', "[/i]", $text);
                $text = str_replace('<li>', "\n[*]", $text);
                $text = str_replace('</li>', '', $text);
                $text = preg_replace('/<span style="font-size:(.*?)pt;">([\s\S]*?)<(?=\/)\/span>/', '[size=\\1]\\2[/size]', $text);
                $text = preg_replace('/<span style="font-size:(.*?)px;line-height:normal;">([\s\S]*?)<(?=\/)\/span>/', '[size=\\1]\\2[/size]', $text);
                $text = preg_replace('/<img src="([\s\S]*?)" class="fr-fic fr-dii".*?>/', '[img]$1[/img]', $text);
                $text = preg_replace('/<a href="([^<]*?)".*?target="_blank".*?>([^<]*?)<\/a>/', '[url=$1]$2[/url]  ', $text);
                $text = preg_replace('/<a href="([\s\S]*?)".*?target="_blank" rel="noopener external noreferrer">([\s\S]*?)<(?=\/)\/a>/', '[url=$1]$2[/url]', $text);
                $text = preg_replace('/<span style="color:rgb([^<]*?);">([^<]*?)<(?=\/)\/span>/', '[color=$1]$2[/color]', $text);
                $text = preg_replace('/<span style="color:([^<]*?);.*?">([^<]*?)<(?=\/)\/span>/', '[color=$1]$2[/color]', $text);
                $text = preg_replace('/<span style="font-weight:bold;">([^<]*?)<(?=\/)\/span>/', '[b]$1[/b]', $text);
                $text = preg_replace('/<span style="text-align:([^<]*?);display:block;">([\s\S]*?)<(?=\/)\/span>/', "[align=\\1]\n\\2\n[/align]", $text);
                $text = preg_replace('/<span align="([^<]*?)">([^<]*?)<(?=\/)\/span>/', "[align=\\1]\\2[/align]", $text);

                $text = preg_replace('/<span style="text-decoration:underline;">([^<]*?)<(?=\/)\/span>/', '[u]$1[/u]', $text);
                $text = preg_replace('/<span class="title_spoiler">([^<]*?)<(?=\/)\/span><span.*?class="text_spoiler" style="display:none;">([^<]*?)<(?=\/)\/span>/', '[spoiler="$1"]$2[/spoiler]', $text);

                //$text = preg_replace('/<!--spoiler_title-->([\s\S]*?)<!--spoiler_title_end-->.*?<!--spoiler_text-->([\s\S]*?)<!--spoiler_text_end--><(?=\/)\/div>/', "[spoiler=\\1]\n\\2\n[/spoiler]", $text);
                    $text = preg_replace('/http:(.*?)fastpic.ru/', "https:$1fastpic.ru/", $text);
                    $text = preg_replace('/http:(.*?)imageban.ru/', "https:$1imageban.ru/", $text);
                    $text = preg_replace('/http:(.*?)youpic.su/', "https:$1youpic.su/", $text);
                    $text = preg_replace('/http:(.*?)lostpic.net/', "https:$1lostpic.net/", $text);
                    $text = preg_replace('/http:(.*?)*******.host/', "https:$1radikal.host/", $text);
                    $text = str_replace('http://img-fotki.yandex.ru', 'https://img-fotki.yandex.ru', $text);
                }

            if(strlen($text) > 55){
                false;
                }
                else{
                $text = preg_replace('#<br />(.*?):#', "[b]$1:[/b] ", $text);
                $text = preg_replace('#<br>(.*?):#', "[b]$1:[/b] ", $text);
                }
                $text = preg_replace('/<a class="highslide" href="(.*?)" target="_blank"><img src=".*?" alt="" class="fr-dib"><\/a>/', '[th]$1[/th]', $text);
                $text = str_replace('Скачать торрент:', "", $text);
                $text = str_replace('Состав раздачи', "", $text);
                $text = str_replace('Показать / Скрыть текст', "", $text);
                $text = preg_replace('/\[url=.*?multi-up.com.*?\].*?\[\/url\]/', "", $text);
                //$text = str_replace('Версия программы:', "[b]Версия программы:[/b]", $text);
               

                // Убираем пустое пространство
                //$text = preg_replace('#([\r\n])[\s]+#is', "$1", $text);
                $text = strip_tags(html_entity_decode($text));
            }
           
                $text = preg_replace_callback('/<a href=".*?">(.*?)<\/a>/', function ($v)
                {
                    return '[url=https://www.hitrustor.me/tracker.php?' . http_build_query(['nm' => $v[1]]) . ']' . $v[1] . '[/url]';
                },
                $text);
            return $text;
        }
Fight for the kingdom, fighting with steel
 
Сверху