Jump to content
Sign in to follow this  
SkellySoul

IE Database

Recommended Posts

SkellySoul

Hello >_<

I am wanting to learn how to store databases from a website.

This website has a ton of members so I thought it would be a great place to learn something and improve my IE coding.

I ran into a problem what this script is suppose to do is get all the members names and than continue to the next page and get more names.

Whats my problem? (If you code out _Skip_Page($Page_Min , $Page_Max) and let the script finish the text file has the names sometimes all of them sometimes not all of them :()

#include <Array.au3>
#include <String.au3>
Opt("OnExitFunc","_Exit")
$Page_Num = 1
$Page_Min = 1
$Page_Max = 1737 ;Allow ini for custom
$Body_Html = @ScriptDir & "\Body Html.txt"
$Members_Log = @ScriptDir & "\Members Log.txt"
$Members_URL = "http://bodyspace.bodybuilding.com/search.php?searchid=22437921"
$oIE = _IECreate()

_Pop_Members($Body_Html , $Members_Log , $Members_URL)

Func _Pop_Members($Body_Html , $Members_Log , $Members_URL)
    If FileExists($Body_Html) Then
        FileDelete($Body_Html)
    EndIf
    
    _IENavigate($oIE, $Members_URL)
    $Body = _IEBodyReadHTML($oIE)
    FileWrite($Body_Html , $Body)
    $File_Open = FileOpen($Body_Html, 0)
    $iCount = 0
        
    While 1
        $iCount += 1
        $File_Read = FileReadLine($File_Open, $iCount)
        If @Error Then
            FileClose($File_Open)
            Exit
        Else
            If StringInStr($File_Read, '<a href="http://bodyspace.bodybuilding.com/') Then
            If '<BR>' = "" Then ExitLoop
            $Found = _StringBetween($File_Read, '/">', '<BR>')
            If IsArray($Found) Then
            FileWrite($Members_Log , $Found[0] & @CRLF)
            _Skip_Page($Page_Min , $Page_Max)
            EndIf
        EndIf
    EndIf
    WEnd
EndFunc

Func _Skip_Page($Page_Min , $Page_Max)
    $Page_Num += 1
    $Members_URL_X = "http://bodyspace.bodybuilding.com/search.php?searchid=22437921&page=" & $Page_Num
    _Pop_Members($Body_Html , $Members_Log , $Members_URL_X)
EndFunc

Func _Exit()
Exit
EndFunc

Share this post


Link to post
Share on other sites
Scriptonize

If you have found a solution, please let me know.

Maybe I can sell it to voidale >_<

Edited by Scriptonize

If you learn from It, it's not a mistake

Share this post


Link to post
Share on other sites
DaleHohm

Sorry, there is a lot of troubleshooting grunt-work you need to do. "Geordi, make it go." doesn't work so well here.

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

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.