 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
WankaUSR
Joined: 14 Aug 2007 Posts: 33
|
Posted: Mon Jul 07, 2008 9:38 am Post subject: extract <object>*</object> from html |
|
|
can anyone help me with a script to extract the <object>*</object> from html
I tried downloading the file and splitting it in 3 sections (before the <object> after <object>and after </object>) by but i always get an empty string
Last edited by WankaUSR on Mon Jul 07, 2008 3:17 pm; edited 2 times in total |
|
| Back to top |
|
 |
HugoV
Joined: 27 May 2007 Posts: 650
|
Posted: Mon Jul 07, 2008 11:36 am Post subject: |
|
|
| code? |
|
| Back to top |
|
 |
WankaUSR
Joined: 14 Aug 2007 Posts: 33
|
Posted: Mon Jul 07, 2008 3:18 pm Post subject: |
|
|
sorry i forgot about the code
| Code: |
UrlDownloadToFile, http://www.gecotv.ro/posturi/12/USA, tmp.txt
SourceFile =tmp.txt
DestFile =links.txt
IfExist, %DestFile%
{
MsgBox, 4,, Overwrite the existing links file? Press No to append to it.`n`nFILE: %DestFile%
IfMsgBox, Yes
FileDelete, %DestFile%
}
LinkCount = 0
Loop, read, %SourceFile%, %DestFile%
{
URLSearchString = %A_LoopReadLine%
Gosub, URLSearch
}
gosub dldobj
return
URLSearch:
StringGetPos, URLStart1, URLSearchString, http://www.gecotv.ro/tvonline/
URLStart = %URLStart1%
Loop
{
ArrayElement := URLStart%A_Index%
if ArrayElement =
break
if ArrayElement = -1
continue
if URLStart = -1
URLStart = %ArrayElement%
else
{
if ArrayElement <> -1
if ArrayElement < %URLStart%
URLStart = %ArrayElement%
}
}
if URLStart = -1
return
StringTrimLeft, URL, URLSearchString, %URLStart%
Loop, parse, URL, %A_Tab%%A_Space%<>
{
URL = %A_LoopField%
break
}
StringReplace, URLCleansed, URL, ",, All
FileAppend, %URLCleansed%`n
LinkCount += 1
StringLen, CharactersToOmit, URL
CharactersToOmit += %URLStart%
StringTrimLeft, URLSearchString, URLSearchString, %CharactersToOmit%
Gosub, URLSearch
return
dldobj:
Loop
{
FileReadLine, line, links.txt, %A_Index%
if ErrorLevel
break
UrlDownloadToFile, %line%, x%A_Index%tmp.txt
gosub extractobj
}
return
extractobj:
;HERE IS WHERE I AM STUCK
FileRead, xobj, x%A_Index%tmp.txt
StringSplit, OBJ, xobj, <object>
msgbox %OBJ1%||||%OBJ2%
;I WANT EXTRACT THE OBJECT CODE FROM IT
return
|
|
|
| Back to top |
|
 |
Trikster
Joined: 15 Jul 2007 Posts: 1224 Location: Enterprise, Alabama
|
Posted: Mon Jul 07, 2008 7:23 pm Post subject: |
|
|
Search for XPath. _________________ ScriptPad | ~dieom | dieom | izwian2k7 | Ian | God |
|
| Back to top |
|
 |
WankaUSR
Joined: 14 Aug 2007 Posts: 33
|
Posted: Tue Jul 08, 2008 11:04 am Post subject: |
|
|
I've looked at XPath but I can't extract HTML code from a web page more exactly the content of an object something like the code below because I don't understand how to use it I mean can the tags from html be used there?
| Code: | <object type="application/x-mplayer2" width="490" height="370" title="****************" standby="*********************">
<param name="autostart" value="true" />
<param name="autoplay" value="true" />
<param name="src" value="*******************" />
<param name="ShowStatusBar" value="1" />
<param name="channelmode" value="1" />
<param name="enableContextMenu" value="0" />
<param name="autosize" value="false" />
<param name="loop" value="true">
<paran name="menu" value="false">
<paran name="displaymode" value="0">
<paran name="allowchangedisplaysize" value="-1">
<param name="stretchToFit" value="false" />
<param name="enableContextMenu" value="True">
<embed src="*******************" width="490" height="370" type="application/x-mplayer2" stretchtofit="0" autoplay="true" autosize="0" menu="false" autostart="true" displaymode="0" allowchangedisplaysize="-1" allowscan="-1" autosize="-1"></embed>
</object> |
I want to extract the adress of the source "embed src=".
I've tried using http://www.autohotkey.com/forum/viewtopic.php?t=30077 but I can't understand the code for me to use it in my script |
|
| Back to top |
|
 |
HugoV
Joined: 27 May 2007 Posts: 650
|
Posted: Wed Jul 09, 2008 10:10 am Post subject: |
|
|
| Code: | code=
(
<html>
<body>
<h1>Object</h1>
.... bla bla website ....
<object type="application/x-mplayer2" width="490" height="370" title="****************" standby="*********************">
<param name="autostart" value="true" />
<param name="autoplay" value="true" />
<param name="src" value="*******************" />
<param name="ShowStatusBar" value="1" />
<param name="channelmode" value="1" />
<param name="enableContextMenu" value="0" />
<param name="autosize" value="false" />
<param name="loop" value="true">
<paran name="menu" value="false">
<paran name="displaymode" value="0">
<paran name="allowchangedisplaysize" value="-1">
<param name="stretchToFit" value="false" />
<param name="enableContextMenu" value="True">
<embed src="*******************" width="490" height="370" type="application/x-mplayer2" stretchtofit="0" autoplay="true" autosize="0" menu="false" autostart="true" displaymode="0" allowchangedisplaysize="-1" allowscan="-1" autosize="-1"></embed>
</object>
.... bla bla website ....
</body>
</html>
)
RegExMatch(code, "sm)(<object.*object>)", Object)
MsgBox % Object1 |
|
|
| Back to top |
|
 |
WankaUSR
Joined: 14 Aug 2007 Posts: 33
|
Posted: Wed Jul 09, 2008 4:04 pm Post subject: |
|
|
| Thanks HugoV, that is just what I wanted |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|