This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
//парсинг с помощью регулярных выражений | |
$url = 'http:///'; | |
$file = file_get_contents($url); | |
$pattern = '#<table class="rates-table-nbrb".+?</table>#s'; | |
preg_match($pattern, $file, $matches); | |
print_r($matches); | |
#<body.+>(.*?)</body>#su //с учетом атрибутов | |
#<div[^>]+?id\s*?=\s*?["\']content["\'][^>]*?>(.+?)</div>#su | |
#<div[^>]+?id\s*?=\s*?(["\'])content\1[^>]*?>(.+?)</div>#su //первая ковычка ложится в карман |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
/////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
$url = 'http://www.kolesa.ru/news/page/1'; | |
$title = pq('title')->html();// получения по селектору | |
$article->find('.class:eq(3)')->text(); // 4 по счету класс | |
$article->find('.cat')->remove(); //удаляем нужный блок с классом | |
$article->find('.cat')->prepend('Категория: '); //добавляем текст в нужный блок с классом | |
$article->find('.cat')->wrap('<div class=category>')->after('Дата:' . date('Y-M-D')); //делаем обертку и добавляемпосле класса .cat дату | |
phpQuery::unloadDocuments($doc); //чистим память | |
$article->find('div.forecast-briefly__day:not(.forecast-briefly__day_weekstart_0)'); //кроме |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
//////////////////////////////////////// | |
var a = $('input[name="var1"]').val(); | |
var b = $('input[name="var2"]').val(); | |
//ajax | |
data: {a:a,b:b}, | |
data: 'a='+a+'&b='+b | |
//////////////////////////////////////// | |
var send = {}; | |
send['a'] = $('input[name="var1"]').val(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); //http/https адрес | |
curl_setopt($ch, CURLOPT_NOBODY, true); //без тела | |
curl_setopt($ch, CURLOPT_HEADER, true); //смотреть заголовки | |
curl_setopt($ch, CURLOPT_COOKIE, 'cookie=777'); //отправляем куки | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); | |
curl_setopt($ch, CURLOPT_POST, 1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Класс для работы с Curl | |
Все функции для вытаскивания данных с сайта | |
/************************ПРИМЕНЕНИЕ******************************** | |
//если нужна авторизация | |
$options['autorization']=1; | |
$options['after_autoriz']='my'; | |
$options['login_page']=URL.'/login'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
class sql { | |
private static $instance; | |
private $db; | |
public static function app() { | |
if (self::$instance == null) { | |
self::$instance = new sql(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
use Sunra\PhpSimple\HtmlDomParser; | |
$html = curl_get('https://ntschool.ru/kursyi'); | |
$dom = HtmlDomParser::str_get_html($html); | |
$courses = $dom->find('.courses-list--item-body'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$cookie = ''; //переменная нужна для сохранения печенек | |
function pageVK($url) { | |
global $cookie; | |
$curl = curl_init($url); | |
curl_setopt($curl,CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER, false); | |
curl_setopt($curl,CURLOPT_SSL_VERIFYHOST, false); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Files cron.php> | |
order deny,allow | |
allow from localhost | |
allow from youhostname | |
allow 123.45.67.89 | |
</Files> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TRUNCATE TABLE %TABLE_NAME% | |
INSERT IGNORE INTO |
OlderNewer