AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

extract <object>*</object> from html

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
WankaUSR



Joined: 14 Aug 2007
Posts: 33

PostPosted: Mon Jul 07, 2008 9:38 am    Post subject: extract <object>*</object> from html Reply with quote

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
View user's profile Send private message Visit poster's website
HugoV



Joined: 27 May 2007
Posts: 650

PostPosted: Mon Jul 07, 2008 11:36 am    Post subject: Reply with quote

code?
Back to top
View user's profile Send private message
WankaUSR



Joined: 14 Aug 2007
Posts: 33

PostPosted: Mon Jul 07, 2008 3:18 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Trikster



Joined: 15 Jul 2007
Posts: 1224
Location: Enterprise, Alabama

PostPosted: Mon Jul 07, 2008 7:23 pm    Post subject: Reply with quote

Search for XPath.
_________________
ScriptPad | ~dieom | dieom | izwian2k7 | Ian | God
Back to top
View user's profile Send private message
WankaUSR



Joined: 14 Aug 2007
Posts: 33

PostPosted: Tue Jul 08, 2008 11:04 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
HugoV



Joined: 27 May 2007
Posts: 650

PostPosted: Wed Jul 09, 2008 10:10 am    Post subject: Reply with quote

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
View user's profile Send private message
WankaUSR



Joined: 14 Aug 2007
Posts: 33

PostPosted: Wed Jul 09, 2008 4:04 pm    Post subject: Reply with quote

Thanks HugoV, that is just what I wanted
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group