PHP . SU
Программирование на PHP, MySQL и другие веб-технологии
Описание: Пожалуйста помогите спарсить график
Поиск в теме | Версия для печати
Facecontrol
Отправлено: 23 Августа, 2019 - 00:33:56
Новичок
Покинул форум
Сообщений всего: 46
Дата рег-ции: Нояб. 2010
Помог: 0 раз(а)
Вообщем есть страница
http://www[dot]tennisprediction[dot]com/[dot][dot][dot];ma_id=823953685
Мне с неё необходимо выдернуть график с названием Form (according to setting)
Я практически не понимаю логику регулярных выражений.
Поэтому не думаю что стоит выкладывать тот бред что я пытался писать 😂 я так понимаю что нужно вытащить с этого куска кода
Спойлер (Отобразить ) CODE (
html ):
скопировать код в буфер обмена
<body >
<div id = "chart3" style = "height: 300px; width: 250px; background-color: rgb(255, 255, 255); position: relative;" class = "jqplot-target" >
<canvas width = "500" height = "600" class = "jqplot-base-canvas" style = "position: absolute; left: 0px; top: 0px; width: 250px; height: 300px;" ></ canvas>
<div class = "jqplot-title" style = "position: absolute; top: 0px; left: 0px; width: 250px; text-align: center;" > Form (according to setting)</ div >
<div class = "jqplot-axis jqplot-xaxis" style = "position: absolute; width: 250px; height: 14px; left: 0px; bottom: 0px;" >
<div class = "jqplot-xaxis-tick" style = "position: absolute; left: 32px;" > -5</ div >
<div class = "jqplot-xaxis-tick" style = "position: absolute; left: 84.25px;" > 0</ div >
<div class = "jqplot-xaxis-tick" style = "position: absolute; left: 135px;" > 5</ div >
<div class = "jqplot-xaxis-tick" style = "position: absolute; left: 182.25px;" > 10</ div >
<div class = "jqplot-xaxis-tick" style = "position: absolute; left: 233px;" > 15</ div >
</ div >
<div class = "jqplot-axis jqplot-yaxis" style = "position: absolute; height: 300px; width: 27px; left: 0px; top: 0px;" >
<div class = "jqplot-yaxis-tick" style = "position: absolute; top: 269px;" > -10.0</ div >
<div class = "jqplot-yaxis-tick" style = "position: absolute; top: 208.25px;" > 0.0</ div >
<div class = "jqplot-yaxis-tick" style = "position: absolute; top: 147.5px;" > 10.0</ div >
<div class = "jqplot-yaxis-tick" style = "position: absolute; top: 86.75px;" > 20.0</ div >
<div class = "jqplot-yaxis-tick" style = "position: absolute; top: 26px;" > 30.0</ div >
</ div >
<canvas width = "500" height = "600" class = "jqplot-grid-canvas" style = "position: absolute; left: 0px; top: 0px; width: 250px; height: 300px;" ></ canvas>
<canvas width = "406" height = "486" class = "jqplot-series-shadowCanvas" style = "position: absolute; left: 37px; top: 33px; width: 203px; height: 243px;" ></ canvas>
<canvas width = "406" height = "486" class = "jqplot-series-shadowCanvas" style = "position: absolute; left: 37px; top: 33px; width: 203px; height: 243px;" >
</ canvas><canvas width = "406" height = "486" class = "jqplot-series-canvas" style = "position: absolute; left: 37px; top: 33px; width: 203px; height: 243px;" ></ canvas>
<canvas width = "406" height = "486" class = "jqplot-series-canvas" style = "position: absolute; left: 37px; top: 33px; width: 203px; height: 243px;" ></ canvas>
<table class = "jqplot-table-legend" style = "right: 10px; bottom: 24px;" >
<tbody >
<tr class = "jqplot-table-legend" >
<td class = "jqplot-table-legend jqplot-table-legend-swatch" style = "text-align: center; padding-top: 0px;" ><div class = "jqplot-table-legend-swatch-outline" >
<div class = "jqplot-table-legend-swatch" style = "background-color: rgb(0, 128, 0); border-color: rgb(0, 128, 0);" ></ div ></ div >
</ td >
<td class = "jqplot-table-legend jqplot-table-legend-label" style = "padding-top: 0px;" > Jeong Sunam</ td >
</ tr >
<tr class = "jqplot-table-legend" >
<td class = "jqplot-table-legend jqplot-table-legend-swatch" style = "text-align: center;" >
<div class = "jqplot-table-legend-swatch-outline" >
<div class = "jqplot-table-legend-swatch" style = "background-color: rgb(255, 0, 0); border-color: rgb(255, 0, 0);" ></ div >
</ div ></ td >
<td class = "jqplot-table-legend jqplot-table-legend-label" > Lee Eunhye (2000)</ td >
</ tr >
</ tbody >
</ table >
<canvas width = "406" height = "486" class = "jqplot-lineRenderer-highlight-canvas" style = "position: absolute; left: 37px; top: 33px; width: 203px; height: 243px;" >
</ canvas>
<canvas width = "406" height = "486" class = "jqplot-event-canvas" style = "position: absolute; left: 37px; top: 33px; width: 203px; height: 243px;" >
</ canvas>
</ div >
</ body >
Помогите пожалуйста.
Facecontrol
Отправлено: 23 Августа, 2019 - 22:14:32
Новичок
Покинул форум
Сообщений всего: 46
Дата рег-ции: Нояб. 2010
Помог: 0 раз(а)
Строитель пишет: Facecontrol пишет: Я практически не понимаю логику регулярных выражений.
А там всё сложно только при поверхностном прочтении. Если перечитать вдумчиво, то всё довольно таки логично и упорядочено.
Подскажи пожалуйста где лучше почитать про регулярки
LIME
Отправлено: 24 Августа, 2019 - 00:11:54
Активный участник
Покинул форум
Сообщений всего: 10732
Дата рег-ции: Нояб. 2010
Помог: 322 раз(а)
.
(Отредактировано автором: 24 Августа, 2019 - 00:58:38)
Facecontrol
Отправлено: 24 Августа, 2019 - 00:22:17
Новичок
Покинул форум
Сообщений всего: 46
Дата рег-ции: Нояб. 2010
Помог: 0 раз(а)
LIME пишет: это xml
Какие регулярки
Все уже структурированно
(Добавление)
А вообще у Котерова "php в подлиннике" наверное самое дохобчивое объяснение для старта. Отдельно главу можно прочитать
Ладно извини, просто я совсем малость изучал php и html Ито давно, а вот сейчас для своих нужд надо скрипт написать один вот и сижу туплю. Сейчас попробую понять как воспользоваться твоим советом. Правда я не совсем понял как это сделать.
(Добавление)
Что то я все равно не пойму как это организовать. Я только с помощью регулярки пытаюсь, xml для меня вообще темный лес, в первый раз с ним столкнулся.
Но и регуляркой тоже не так то и просто. Понял что с этого участка
Спойлер (Отобразить ) CODE (
htmlphp ):
скопировать код в буфер обмена
------MultipartBoundary--CqGdqQdT9jiN5WLQOzH0PQkxSRcsu3VF8bpoIirWRp----
Content-Type: text/html
Content-ID: < frame- 2DC98E9F5D0CA541324C92011400F005@ mhtml. blink>
Content-Transfer-Encoding: binary
Content-Location: http://www.tenisinfo.eu/graph.php?a0=0|-3|-6|-3&a1=0|3|6|9|12|15|18|21|24||24|21|24&p1_name=Jeong%20Sunam&p12_name=%20&p2_name=Lee%20Eunhye%20(2000)&p22_name=%20&lng=1
Нужно выдернуть вот эту ссылку
http://www[dot]tenisinfo[dot]eu/graph[dot]ph[dot][dot][dot]me=%20&lng=1
Пытался с помощью регулярки, но так как я мега спец. Ничего не вышло.
Помогите пожалуйста мне буду очень признателен.
Вот если что большая часть кода откуда нужно выдернуть.
Спойлер (Отобразить ) Content-Type: image/gif
Content-Transfer-Encoding: binary
Content-Location:
http://toplist[dot]cz/dot[dot]asp?id=282[dot][dot][dot]nis%20Prediction
GIF89a��€�����ÿÿÿ!ù���,�������L�;
------MultipartBoundary--CqGdqQd T9jiN5WLQOzH0PQkxSRcsu3VF8bpoIir WRp----
Content-Type: text/html
Content-ID: <frame-2DC98E9F5D0CA541324C92011400F005@mhtml.blink>
Content-Transfer-Encoding: binary
Content-Location:
http://www[dot]tenisinfo[dot]eu/graph[dot]ph[dot][dot][dot]me=%20&lng=1
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="http://www.tenisinfo.eu/jqplot/jquery.jqplot.min.css">
</head><body><div id="chart3" style="height: 300px; width: 250px; background-color: rgb(255, 255, 255); position: relative;" class="jqplot-target"><canvas width="500" height="600" class="jqplot-base-canvas" style="position: absolute; left: 0px; top: 0px; width: 250px; height: 300px;"></canvas><div class="jqplot-title" style="position: absolute; top: 0px; left: 0px; width: 250px; text-align: center;">Form (according to setting)</div><div class="jqplot-axis jqplot-xaxis" style="position: absolute; width: 250px; height: 14px; left: 0px; bottom: 0px;"><div class="jqplot-xaxis-tick" style="position: absolute; left: 32px;">-5</div><div class="jqplot-xaxis-tick" style="position: absolute; left: 84.25px;">0</div><div class="jqplot-xaxis-tick" style="position: absolute; left: 135px;">5</div><div class="jqplot-xaxis-tick" style="position: absolute; left: 182.25px;">10</div><div class="jqplot-xaxis-tick" style="position: absolute; left: 233px;">15</div></div><div class="jqplot-axis jqplot-yaxis" style="position: absolute; height: 300px; width: 27px; left: 0px; top: 0px;"><div class="jqplot-yaxis-tick" style="position: absolute; top: 269px;">-10.0</div><div class="jqplot-yaxis-tick" style="position: absolute; top: 208.25px;">0.0</div><div class="jqplot-yaxis-tick" style="position: absolute; top: 147.5px;">10.0</div><div class="jqplot-yaxis-tick" style="position: absolute; top: 86.75px;">20.0</div><div class="jqplot-yaxis-tick" style="position: absolute; top: 26px;">30.0</div></div><canvas width="500" height="600" class="jqplot-grid-canvas" style="position: absolute; left: 0px; top: 0px; width: 250px; height: 300px;"></canvas><canvas width="406" height="486" class="jqplot-series-shadowCanvas" style="position: absolute; left: 37px; top: 33px; width: 203px; height: 243px;"></canvas><canvas width="406" height="486" class="jqplot-series-shadowCanvas" style="position: absolute; left: 37px; top: 33px; width: 203px; height: 243px;"></canvas><canvas width="406" height="486" class="jqplot-series-canvas" style="position: absolute; left: 37px; top: 33px; width: 203px; height: 243px;"></canvas><canvas width="406" height="486" class="jqplot-series-canvas" style="position: absolute; left: 37px; top: 33px; width: 203px; height: 243px;"></canvas><table class="jqplot-table-legend" style="right: 10px; bottom: 24px;"><tbody><tr class="jqplot-table-legend"><td class="jqplot-table-legend jqplot-table-legend-swatch" style="text-align: center; padding-top: 0px;"><div class="jqplot-table-legend-swatch-outline"><div class="jqplot-table-legend-swatch" style="background-color: rgb(0, 128, 0); border-color: rgb(0, 128, 0);"></div></div></td><td class="jqplot-table-legend jqplot-table-legend-label" style="padding-top: 0px;">Jeong Sunam</td></tr><tr class="jqplot-table-legend"><td class="jqplot-table-legend jqplot-table-legend-swatch" style="text-align: center;"><div class="jqplot-table-legend-swatch-outline"><div class="jqplot-table-legend-swatch" style="background-color: rgb(255, 0, 0); border-color: rgb(255, 0, 0);"></div></div></td><td class="jqplot-table-legend jqplot-table-legend-label">Lee Eunhye (2000)</td></tr></tbody></table><canvas width="406" height="486" class="jqplot-lineRenderer-highlight-canvas" style="position: absolute; left: 37px; top: 33px; width: 203px; height: 243px;"></canvas><canvas width="406" height="486" class="jqplot-event-canvas" style="position: absolute; left: 37px; top: 33px; width: 203px; height: 243px;"></canvas></div>
</body></html>
Строитель
Отправлено: 24 Августа, 2019 - 11:27:14
Участник
Покинул форум
Сообщений всего: 1581
Дата рег-ции: Февр. 2014
Откуда: Украина
Помог: 74 раз(а)
Facecontrol PHP:
скопировать код в буфер обмена
$str = '------MultipartBoundary--CqGdqQdT9jiN5WLQOzH0PQkxSRcsu3VF8bpoIirWRp----
Content-Type: text/html
Content-ID: <frame-2DC98E9F5D0CA541324C92011400F005@mhtml.blink>
Content-Transfer-Encoding: binary
Content-Location: http://www.tenisinfo.eu/graph.php?a0=0|-3|-6|-3&a1=0|3|6|9|12|15|18|21|24||24|21|24&p1_name=Jeong%20Sunam&p12_name=%20&p2_name=Lee%20Eunhye%20(2000)&p22_name=%20&lng=1' ;
$patt = '~Content-Location: http://\S+~' ;
$url = preg_match ( $patt , $str , $url ) ?
$url [ 0 ] : '' ;
echo $url ;
Facecontrol
Отправлено: 24 Августа, 2019 - 19:16:58
Новичок
Покинул форум
Сообщений всего: 46
Дата рег-ции: Нояб. 2010
Помог: 0 раз(а)
Строитель пишет: Facecontrol PHP:
скопировать код в буфер обмена
$str = '------MultipartBoundary--CqGdqQdT9jiN5WLQOzH0PQkxSRcsu3VF8bpoIirWRp----
Content-Type: text/html
Content-ID: <frame-2DC98E9F5D0CA541324C92011400F005@mhtml.blink>
Content-Transfer-Encoding: binary
Content-Location: http://www.tenisinfo.eu/graph.php?a0=0|-3|-6|-3&a1=0|3|6|9|12|15|18|21|24||24|21|24&p1_name=Jeong%20Sunam&p12_name=%20&p2_name=Lee%20Eunhye%20(2000)&p22_name=%20&lng=1' ;
$patt = '~Content-Location: http://\S+~' ;
$url = preg_match ( $patt , $str , $url ) ?
$url [ 0 ] : '' ;
echo $url ;
спасибо вам большое. Получилось почти то что я хотел, но единственное уточнение, я может неправильно высказал что хотел бы получить.
Дело в том что Content-Location: http:// может быть множество, понятное дело выбираю их через preg_match_all()
Но мне возвращает массив типо Content-Location: http://любая последовательность символов.
А мне нужно выбрать именно Content-Location: http://www.tenisinfo.eu/graph.php?a0=0|-3|-6|-3&a1=0|3|6|9|12|15|18|21|24|21|24|21|24&p1_name=Jeong%20Sunam&p12_name=%20&p2_name=Lee%20Eunhye%20(2000)&p22_name=%20&lng=1";
И заметил я то что есть один Content-Location: http://www[dot]tenisinfo[dot]eu/graph.php?a0=
А после равно уже может иди любая последовательность символов. Стоит. Вопрос как организовать чтоб скрипт находил именно такой вариант ссылки?
(Добавление)
О походу нашел как $patt = '~http://www.tenisinfo.eu/graph.php\?a0=\S+~';
(Добавление)
Но не пойму в чём причина, как будто обрезает ссылку
Возвращает
www[dot]tenisinfo[dot]eu/graph.php?a0=0|[dot][dot][dot]mp;p1_name=Jeong
Хотя должно быть так
www.tenisinfo.eu/graph.php?a0=0|-3|-6|-3&a1=0|3|6|9|12|15|18|21|24|21|24|21|24&p1_name=Jeong%20Sunam&p12_name=%20&p2_name=Lee%20Eunhye%20(2000)&p22_name=%20&lng=1(Отредактировано автором: 24 Августа, 2019 - 19:45:33)
Facecontrol
Отправлено: 25 Августа, 2019 - 00:54:38
Новичок
Покинул форум
Сообщений всего: 46
Дата рег-ции: Нояб. 2010
Помог: 0 раз(а)
Вообщем как говорится начали за здравие...
Проблема ещё одна получилась. Вообщем ссылку грубо говоря получил, правда обрезанную, но дело в другом, я хотел спарсить график.
PHP:
скопировать код в буфер обмена
$url2 = "http://www.tenisinfo.eu/graph.php?a0=0|-3|-6|-3&a1=0|3|6|9|12|15|18|21|24|21|24|21|24&p1_name=Jeong%20Sunam&p12_name=%20&p2_name=Lee%20Eunhye%20(2000)&p22_name=%20&lng=1" ;
echo $site2 ;
Но почему то мне ничего не выдает, пустой экран.
Думал может защита какая на сайте от парсинга, так нет главную то парсит, а вот отдельно график не хочет.
Скрин графика внизу.Прикреплено изображение (Нажмите для увеличения)
Поиск в теме | Версия для печати
Страниц (1): [1]
Сейчас эту тему просматривают: 0 (гостей: 0, зарегистрированных: 0)
« Регулярные выражения »
Все гости форума могут просматривать этот раздел. Только зарегистрированные пользователи могут создавать новые темы в этом разделе. Только зарегистрированные пользователи могут отвечать на сообщения в этом разделе.
Powered by ExBB FM 1.0 RC1. InvisionExBB