Jump to content

Retrieving certain text from a bunch of text


Recommended Posts

You need to read the help file. The function description is clear.

_INetGetSource

Gets the source from an URL without writing a temp file.

#include <INet.au3>

_INetGetSource ( $s_URL )

Parameters

$s_URL (The URL of the site.) eg 'www.autoitscript.com'

So in the case you tried automating an internet explorer window or firefox it's still not the parameter the function expects.

Link to comment
Share on other sites

You need to read the help file. The function description is clear.

So in the case you tried automating an internet explorer window or firefox it's still not the parameter the function expects.

Sorry, got a little confused in that last sentence. So your saying that when it gets the source code, when I put it in a MsgBox it won't show anything because only the function has it? I would need to write it down in a notepad or .ini first, then read it from there? ><

EDIT:

I tried this:

Dim $sHTML = _INetGetSource($Title)
If @error Then
    MsgBox(0,"","BLEH")
EndIf

And it did show up as an error. (The MsgBox appeared)... Which means according to the HelpFile

Success: Returns the source code.

Failure: 0 and sets @ERROR = 1

So its not reading the source code? ><

Edited by UnknownWarrior
Link to comment
Share on other sites

Heh :) I guess that the source of the page that you want to get is not something in the form:

"Title - Mozilla FireFox" or "Title - Internet Explorer".

By page I mean, www.autoitscript.com/forum/index.php, for example. So it what the navigator URL edit control shows in the top of the internet browser.

Link to comment
Share on other sites

Heh :) I guess that the source of the page that you want to get is not something in the form:

"Title - Mozilla FireFox" or "Title - Internet Explorer".

By page I mean, www.autoitscript.com/forum/index.php, for example. So it what the navigator URL edit control shows in the top of the internet browser.

Doye ><... My bad... Let me test it now xD

EDIT: Woohoo! It works :)... Only one thing that is minor... Do you think there is a way to speed up the typing of the source? Because this page source is like 30 KB's of text... And it would take like 3-5 mins to write it all down xD... Maybe something with the StringRegExp or something, not sure how you could incorporate that with _INetGetSource though.

Edited by UnknownWarrior
Link to comment
Share on other sites

Are you using Send() function to preform a 30K ~ keystrokes? :) You can save it to a file or parse it right after the variable contain the data. If you want to save to a file and then read it's better to use InetGet() function instead, but for this specific case I think that _INetGetSource() is more appropriate because you don't need any intermediate level to parse the data. Can you post a script of what you got so far?

Link to comment
Share on other sites

Are you using Send() function to preform a 30K ~ keystrokes? :) You can save it to a file or parse it right after the variable contain the data. If you want to save to a file and then read it's better to use InetGet() function instead, but for this specific case I think that _INetGetSource() is more appropriate because you don't need any intermediate level to parse the data. Can you post a script of what you got so far?

ControlSend ><

And yeah... I've toying with it a bunch, read the comment spaces as well.

HotKeySet("{ESC}","Terminate")
#include <INet.au3>

Sleep(5000)

;Global $Title = WinGetTitle("[active]")






Dim $hey = _INetGetSource('http://bbs.co.91.com/memberlist.php')
If @error Then
    MsgBox(0,"","BLEH")
EndIf

ControlSend("Untitled", "", "Edit1", $hey)

Dim $sHTML = ControlGetText("[CLASS:Notepad]", "", "Edit1")



Dim $sPatt = '(?s)(?i)<td.*?id="([^"]*).*?<a.*?href="([^"]*)[^>]*>([^<]*)'
Dim $aMatch = StringRegExp($sHTML, $sPatt, 3)

If IsArray($aMatch) Then
    For $i = 0 To UBound($aMatch)-1 Step 3
        Local $ID = $aMatch[$i]
        Local $Profile = $aMatch[$i+1]
        Local $Username = $aMatch[$i+2]
        MsgBox(0x40, 'User Info:', 'Link: ' & $Profile & @CRLF & 'User ID: ' & $ID & @CRLF & 'User Name: ' & $Username)
    Next
EndIf

Func Terminate()
    Exit
EndFunc

And I didn't let it type all the source code out... But I took about 12 names of coding from the page source, copied it into the Notepad, used the ControlGetText... And it retrieved exactly what it's suppose to!! :) (Name, ID, etc xD)

I did also notice, when it was ControlSending it into the notepad, it was getting VERY glitchy when typing... It kept clicking 'File' at the top of the notepad page, and after a while it erased the entire screen and kept going... I doubt it ran out of space, but would Send be a better idea to use?

Edited by UnknownWarrior
Link to comment
Share on other sites

You can use ControlSetText(), although nothing like this is requires, i.e. eventually, $sHTML will contain ~exactly what $hey already contain. Just check the @error as you did and pass it as a whole to the StringRegExp() function. You can play with the example to eventually build a long string or maybe an array holding the ID's, names etc...

You may want to look into StringSplit() or the "Variables" section in the help file to expand this to understand better the spices of the language to decide later which way is more appropriate.

Link to comment
Share on other sites

You can use ControlSetText(), although nothing like this is requires, i.e. eventually, $sHTML will contain ~exactly what $hey already contain. Just check the @error as you did and pass it as a whole to the StringRegExp() function. You can play with the example to eventually build a long string or maybe an array holding the ID's, names etc...

You may want to look into StringSplit() or the "Variables" section in the help file to expand this to understand better the spices of the language to decide later which way is more appropriate.

Ahh poo, your right... I tried that before, but that's before when I did _INetGetSource($Title) [instead of the URL]...

Works like a charm exluding one tiny thing which really isn't too big of a deal, though I thought I'd point it out... There must be coding somewhere in the script that has the exact same thing as the StringRegExp() that we defined... Because it retrieves 2 'Names' and 'ID's that aren't actual names... They are some random stuff from the coding. xP

Do you think, as a real quick thing (I'm gonna study up on my StringRegExp :)).... Could you take this:

Dim $sPatt = '(?s)(?i)<td.*?id="([^"]*).*?<a.*?href="([^"]*)[^>]*>([^<]*)'

And put like 2 spaces between each of the 'Matching Character' symbol stuff... (And if you have extra time, maybe explain what each one does? ><)... I'm thinking this might be helpful in the future if I can get the hang of it.

Thanks a bunch nonetheless... Working great now... Now all I have to do is automate typing in a webpage to 'Send new Message', type in the usernames, then type the message I need to get to them.

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...