Jump to content

Seriously Stumpped


Recommended Posts

I am totally clueless on how this would be done..

I have a file "\includes\temp.txt" and it has a lot of random code in it that I want to get rid of:

<br/><br/><div class=""><div class=""><table><thead><tr ""><th>image<th>expire<th>size<th>time</tr><tbody><tr class=""><td><img width=300 src="/files/38j9sd8fjf893fn8undsf8n32oifnsdfkln023.408.random.png"><BR>RESULT: GE7UWH<BR><small><a href=""></a></small><td>300<td>166x75<td><BR><BR></tr><tr class=""><td><img width=300 src="/files/43g90dfgj340gjd90fg.43g834gj.png"><BR>RESULT: 888RHJ<BR><small><a href=""></a></small><td><td><td><BR> <BR></tr><tr class=""><td><img width= src="/files/3dfgkjopkpofgk90340gk.dfkjgim4g8imoiejgerg.png"><BR>RESULT: 9FZOOZ<BR><small>

This is all one line of code already, but its very very long... I am looking for one thing, I am looking for the result of an image.

Example:

Lets say I wanted the result for the image "/files/38j9sd8fjf893fn8undsf8n32oifnsdfkln023.408.random.png" ( Second line in quote ) how would I find that?

The Result is always going to be between the <BR> tags.. so if there was a way to do a search for "408.random.png" then erase everything before that and erase the next 14 spaces over that will put me right before the result I want in this case right before the G, but sometimes the result will be different lengths so maybe keep everything until it gets to the next "<BR>".

I think that would be the right way to do it, but I am not sure how to do it.. could anyone please help me here?

P.S. - Sorry if it sounds really confusing or don't make since.. I have been up for a very long time with no sleep. :)

Link to comment
Share on other sites

yes, i have got same problem, let's say i have text and i have words in "xxxx" whats the command to copy only the text in ""

it looks like this

1360481,"xxxxxx"
1360482,"yyyyyyyy"
1360483,"wwwwwww"
1360484,"zzzzz"
1360485,"qqqqqqq"
1360486,"uuuuuuuu"
Link to comment
Share on other sites

yes, i have got same problem, let's say i have text and i have words in "xxxx" whats the command to copy only the text in ""

it looks like this

1360481,"xxxxxx"
 1360482,"yyyyyyyy"
 1360483,"wwwwwww"
 1360484,"zzzzz"
 1360485,"qqqqqqq"
 1360486,"uuuuuuuu"
Potrus, please make your own request for help.

Your question is very different than the OP... and easier also

However, to help you kinda "hijacks" this thread

8)

NEWHeader1.png

Link to comment
Share on other sites

I was recently working on something like what you are asking for. The code I have works, but it is a little buggy. It should give you some direction on how to solve the problem.

Func _name()
    SplashTextOn("Processing Request",$iMax& " Service Request found... Processed "&$w&" so far...", 200, 100)
    if StringIsAlNum($array[$w]) then
        $ie1 = _IECreate($links[$w], 0, 0)
        $read = _IEbodyReadHTML($ie1)
        $stt = StringInStr($read, '>First Name<',0 )
        $stri = Stringmid($read, $stt+50, 50)   
        $firstname = StringSplit($stri, "</FONT>",1)
        $stt2 = StringInStr($read, '>Last Name<',0 )
        $stri2 = Stringmid($read, $stt2+49, 50) 
        $lastname = StringSplit($stri2, "</FONT>",1)
        $listedname = $firstname[1]&" "&$lastname[1] ;name
        ;------------------------------------------------------
        ;comments
        $sttc = StringInStr($read, '>Comments</font></u><br>',0 )
        $stend = StringInStr($read,'>Internal Comments',0)
        $stmidCommentsA = StringMid($read, $sttc+20, $stend - ($sttc+50))
        $stmidComments = '<b>Comments:</b><br>'&$stmidCommentsA

        ;------------------------------------------------------
        ;summary
        $stSS = StringInStr($read, '>Description</font>',0 )
        $stendSS = StringInStr($read,'>COST CENTER<b>',0)
        $stmidSummery1 = StringMid($read, $stSS+240, $stendSS - ($stSS+566))
        $chkst = StringInStr($stmidSummery, '</td></tr>')
        $stmidSummery = '<b>Summary:</b></b>'&$stmidSummery1
        if $chkst >1 then 
            $lenth = StringLen($stmidSummery)
            $clip = StringLeft($stmidSummery, $chkst-1)
        $stmidSummery = '<b>Summary:</b></b>'&$clip
        endif       
        ;------------------------------------------------------
        ;vam orders
        $stSV = StringInStr($read, '>VAM Orders:<',0 )
        $stendV = StringInStr($read,'>Received Date(s):<',0)
        if $stSV = 0 then 
            $stmidVAM = "No Order Placed"
        Else
            $stmidVAM = StringMid($read, $stSV+163, $stendV - ($stSV+204))
        endif
        $final = '<td>'&$stmidSummery&'><p><br>'&$stmidComments&'</td>'  & @CR ;        
        _IEQuit($ie1)

    ElseIf StringInStr($Array[$w], " - 0") > 0 then 
        
        $ie1 = _IECreate($links[$w], 0, 0)
        $read = _IEbodyReadHTML($ie1)
        $stt = StringInStr($read, 'Request Owner (customer liaison)',0 )
        $stri2 = Stringmid($read, $stt+71, 50) ; has the name       
        $fullname1 = StringSplit($stri2, "</FONT>",1)
        $listedname = $fullname1[1] 
        ;------------------------------------------------------
        ;comments
        $sttc = StringInStr($read, '>Comments</font></u><br>',0 )
        $stend = StringInStr($read,'>Hours Worked</font>',0)
        $stmidComments = StringMid($read, $sttc+20, $stend - ($sttc+50))
;~      
;~      ;------------------------------------------------------
;~      ;summary
;~      $stSS = StringInStr($read, '>Description</font>',0 )
;~      $stendSS = StringInStr($read,'>COST CENTER<b>',0)
;~      $stmidSummery = StringMid($read, $stSS+240, $stendSS - ($stSS+566))     
        _IEQuit($ie1)
        
    else  
        if StringInStr($Array[$w], " - s") > 0 then 
            
            $ie1 = _IECreate($links[$w], 0, 0)
            $read = _IEbodyReadHTML($ie1)
            $stt = StringInStr($read, 'Work OrderOwner (customer liaison)',0 )
            $stri2 = Stringmid($read, $stt+73, 50) ; has the name       
            $fullname1 = StringSplit($stri2, "</FONT>",1)
            $listedname = $fullname1[1] 
            _IEQuit($ie1)
        endif
    endif
SplashOff() 
EndFunc
Link to comment
Share on other sites

Lets say I wanted the result for the image "/files/38j9sd8fjf893fn8undsf8n32oifnsdfkln023.408.random.png" ( Second line in quote ) how would I find that?

The Result is always going to be between the <BR> tags.. so if there was a way to do a search for "408.random.png" then erase everything before that and erase the next 14 spaces over that will put me right before the result I want in this case right before the G, but sometimes the result will be different lengths so maybe keep everything until it gets to the next "<BR>".

I think that would be the right way to do it, but I am not sure how to do it.. could anyone please help me here?

See if this helps:

Local $i, $z, $x = '<br/><br/><div class=""><div class=""><table><thead><tr ""><th>image<th>expire<th>size<th>time</tr><tbody><tr class=""><td><img width=300 src="/files/38j9sd8fjf893fn8undsf8n32oifnsdfkln023.408.random.png"><BR>RESULT: GE7UWH<BR><small><a href=""></a></small><td>300<td>166x75<td><BR><BR></tr><tr class=""><td><img width=300 src="/files/43g90dfgj340gjd90fg.43g834gj.png"><BR>RESULT: 888RHJ<BR><small><a href=""></a></small><td><td><td><BR> <BR></tr><tr class=""><td><img width= src="/files/3dfgkjopkpofgk90340gk.dfkjgim4g8imoiejgerg.png"><BR>RESULT: 9FZOOZ<BR><small>'

Local $re = '/files/.*?\.408\.random\.png'

Local $found = StringRegExp($x, $re, 3)

If IsArray($found) Then
   For $i = 0 To UBound($found) - 1
      $z = $found[$i]
   Next
EndIf
My Projects:DebugIt - Debug your AutoIt scripts with DebugIt!
Link to comment
Share on other sites

If there are consistant patterns in the HTML structure (like is the data you are after always contained in a table?) then there can be very simple, efficient ways to cull what you need out of the Document Object Model (DOM) without having to parse strings down to the level in previous replies. There is nothing wrong with that approach however.

In order to make any further suggestions along those lines, we'd need to see more of the HTML source.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...