Must AutoIt
Сообщения: 3054
Благодарности: 1009
|
Профиль
|
Сайт
|
Отправить PM
| Цитировать
Medic84,
Вот подправил:
Код: 
#include <IE.au3>
$sURL = "http://www.kinopoisk.ru/level/1/film/5090"
$sURL = InputBox("Kinopoisk.ru Informer", "Введите ссылку на фильм для получения информации:", $sURL, "", 350, 200)
If @error Then Exit
$oIE = _IECreate($sURL, 0, 0)
$sSource = _IEDocReadHTML($oIE)
_IEQuit($oIE)
$sName = _GetSourceProperty($sSource, '', '(?si).*?<h1 class=moviename-big.*?>(.*?)</h1>.*')
$sSlogan = _GetSourceProperty($sSource, 'слоган')
$sBudget = _GetSourceProperty($sSource, 'бюджет')
$sYear = _GetSourceProperty($sSource, 'год')
$sCountry = _GetSourceProperty($sSource, 'страна')
$sWorld_Primier = _GetSourceProperty($sSource, 'премьера (мир)')
$sRF_Primier = _GetSourceProperty($sSource, 'премьера (РФ)')
$sOriginal = _GetSourceProperty($sSource, '', '(?si).*?<span style="color:.*? font-size:.*?">(.*?)</span>.*')
$sDirector = _GetSourceProperty($sSource, 'режиссер')
$sWorld_Collect = _GetSourceProperty($sSource, 'сборы в мире')
$sTime = _GetSourceProperty($sSource, 'время')
$Kratk = _GetSourceProperty($sSource, '', '(?si).*?<span class=_reachbanner_.*?>(.*?)</span>.*')
$sJaners = _GetSourceProperty($sSource, 'жанр')
$sInfo = StringFormat( _
"Имя:\t\t\t%s\n" & _
"Слоган:\t\t\t%s\n" & _
"Бюджет:\t\t\t%s\n" & _
"Год:\t\t\t%s\n" & _
"Страна:\t\t\t%s\n" & _
"Режиссер:\t\t%s\n" & _
"Премьера (Мир):\t\t%s\n" & _
"Сборы в мире:\t\t%s\n" & _
"Премьера (РФ):\t\t%s\n" & _
"Время:\t\t\t%s\n" & _
"Жанр:\t\t\t%s", _
$sName, $sSlogan, $sBudget, $sYear, $sCountry, $sDirector, $sWorld_Primier, $sWorld_Collect, $sRF_Primier, $sTime, $sJaners)
MsgBox(64, 'Kinopoisk.ru Info', $sInfo)
;Функция для получения подстроки по заданному pattern
Func _GetSourceProperty($sSource, $sName, $sPattern = '')
Local $s_Pattern = _
'(?si).*?<TD class=type>%s</TD>.*?<TD(?: class=.*?|)>' & _
'(?:<A(?: class=.*?|) href=".*?">|)(.*?)(?:</A>|)</TD></TR>.*'
If $sPattern <> '' Then $s_Pattern = $sPattern
$s_Pattern = StringFormat($s_Pattern, "\Q" & $sName & "\E")
Local $sRet = StringRegExpReplace($sSource, $s_Pattern, '\1')
If @extended = 0 Then Return SetError(1, 0, "N/A")
$sRet = _ContentReplaceTags($sRet, 2)
$sRet = StringRegExpReplace($sRet, '«+|»+', '"')
Return $sRet
EndFunc
Func _ContentReplaceTags($sString, $iCorrect=-1)
Local $aCorrects_Arr[8][2] = [[7], _
['&qu' & 'ot;', '"'], ['&a' & 'mp;', '&'], ['&' & '#39;', "'"], _
['&ap' & 'os;', "'"], ['&g' & 't;', '>'], ['&l' & 't;', '<'], ['&nb' & 'sp;', ' ']]
Local $sReplStr = '\\n'
If $iCorrect = 2 Then $sReplStr = @CRLF
Local $sRet_Content = StringRegExpReplace($sString, '(?i)<(/|)br(/| /|)>|\n|\r|\r\n', $sReplStr)
$sRet_Content = StringRegExpReplace($sRet_Content, '(?si)<(/|)[abiu]( .*?|)>|<hr(/| /|)>', '')
For $i = 1 To $aCorrects_Arr[0][0]
$sRet_Content = StringReplace($sRet_Content, $aCorrects_Arr[$i][0], $aCorrects_Arr[$i][1])
Next
If $iCorrect = 1 Then Return $sRet_Content
Local $iCheckSpanPos = StringInStr($sRet_Content, '</s>')
If $iCheckSpanPos > 0 Then $sRet_Content = StringTrimLeft($sRet_Content, $iCheckSpanPos)
Return $sRet_Content
EndFunc
А что такое $sOriginal?
P.S
Кстати, кроме «& nbsp;» ещё могут встречаться и другие теги(?), у меня где то была функция для их полной замены...
|