Собственно скрипт:
<?php
header("Content-Type: text/html; charset=utf-8");
$filename = '00.html';
$resource = file_get_contents($filename);
echo $filename . "\n<BR>";
$pattern = "/subject\"\>(.*?)\\n/";
preg_match($pattern, $resource, $subject);
echo "<b>Subject: </b>" . $subject[1] . "\n<BR>";
$pattern = "/mailto=(.*?)\"/";
preg_match_all($pattern, $resource, $email);
$pattern = "/\xD1\x81\xD1\x83\"\>(.*?)\<\/a/";
preg_match_all($pattern, $resource, $name);
for ($i = 0; $i < 3; $i++) {
$email[1][$i] = urldecode($email[1][$i]);
echo "<" . $name[1][$i] . "> " . $email[1][$i] . "\n<BR>";
}
$pattern = "/class=\"msg-body\"(.*?)span/s";
preg_match($pattern, $resource, $temp);
$pattern = "/br\>(.*?)\<span/s";
preg_match($pattern, $temp[0], $body);
echo "<b>Text: </b>\n<BR>" . $body[1] . "\n<BR>";
$pattern = "/message-attach msg-file-download(.*?)\/a/s";
preg_match_all($pattern, $resource, $temp);
echo "<b>Attached files: </b>\n<BR>";
for ($i = 0;; $i++) {
if ($temp[1][$i] == "")
break;
$pattern = "/f=\"(.*?)\"/";
preg_match($pattern, $temp[1][$i], $link);
$pattern = "/\"\>(.*?)\</";
preg_match($pattern, $temp[1][$i], $namelink);
echo $namelink[1] . " -- http://mail.rambler.ru/mail/" . $link[1] . "\n<BR>";
}
?>
Спустя 5 часов, 51 минута, 26 секунд (22.06.2011 - 19:53) icell написал(а):
Очень нужно до завтра разобраться, сам не въезжаю...
Спустя 3 часа, 40 минут, 2 секунды (22.06.2011 - 23:33) walerus написал(а):
все адреса email - это какие ?
От кого: Кому: Копия: - они ?
От кого: Кому: Копия: - они ?
Спустя 32 минуты, 12 секунд (23.06.2011 - 00:05) walerus написал(а):
Собственно как то так...
PHP скрипт.
Результат.
Вроде все
PHP скрипт.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Test</title>
</head>
<body>
<?
error_reporting(E_ALL);
$files = array('00.html', '01.html');
foreach($files as $file)
{
$tmp = file_get_contents($file);
$tmp = urldecode($tmp);
echo "Обрабатываем файл - $file\n<br>";
// Поиск темы сообщения
preg_match('~<span class="c_message-msg-subj">(.*)</span>~iUs', $tmp, $match_topic);
$topic = trim ( $match_topic[1] );
// Поиск мыл
preg_match_all('~mailto=(.*)" title~iUs', $tmp, $match_mail);
$mail = trim ( $match_mail[1][0] ); // От кого:
$mail_1 = trim ( $match_mail[1][1] ); // Кому:
$mail_2 = trim ( $match_mail[1][2] ); // Копия:
// Текст мыла
preg_match('~<table cellpadding="0" cellspacing="0" border="0" class="msg-body" >(.*)</table>~iUs', $tmp, $match_text);
preg_match('~<td>(.*)</td>~iUs', $match_text[1], $match_text);
$text = trim ( $match_text[1] );
// Ссылки на аттач
preg_match_all('~class="message-attach msg-file-download" href="(.*)" title~iUs', $tmp, $match_attach);
if (isset($match_attach[1]) && trim($match_attach[1][0]) != '')
$attach_file = $match_attach[1];
else
$attach_file = array();
echo "Тема: '$topic'\n<br>";
echo "От кого: '$mail'\n<br>";
echo "Кому: '$mail_1'\n<br>";
echo "Копия: '$mail_2'\n<br>";
echo "<hr>Текст:<br>$text\n<hr>";
echo "Аттач:<pre>";
print_r($attach_file);
echo "</pre><hr><hr>";
}
?>
</body>
</html>
Результат.
Обрабатываем файл - 00.html
Тема: 'тема'
От кого: 'alexey.stoyko@list.ru'
Кому: 'alexey.stoyko@yandex.ru'
Копия: 'alexey-stoyko@lenta.ru'
Текст:
This document is intended for programmers who want to write client applications that can interact with Google Documents. It provides a series of examples of basic data API interactions using raw XML/HTTP, with explanations. After reading this document, you can learn more about interacting with the API using our client libraries by reading the language-specific examples found on the other tabs at the top of this document.
--
Современная мобильная почта - для смартфонов и телефонов.
Оцените мобильный m.mail.ru с Вашего телефона
Аттач:
Array
(
[0] => download/winscp432.zip?mode=obj;mbox=INBOX;what=3.2;for=download
[1] => download/zlib-1.2.5.tar.gz?mode=obj;mbox=INBOX;what=3.3;for=download
)
Обрабатываем файл - 01.html
Тема: 'тема'
От кого: 'alexey.stoyko@yahoo.com'
Кому: 'alexey.stoyko@gmail.com'
Копия: 'alexey-stoyko@lenta.ru'
Текст:
текст Аттач:
Array
(
[0] => download/galant.pdf?mode=obj;mbox=Trash;what=1.2;for=download
[1] => download/lancerX.pdf?mode=obj;mbox=Trash;what=1.3;for=download
[2] => download/Outlander.pdf?mode=obj;mbox=Trash;what=1.4;for=download
)
Вроде все