Jump to content
Sign in to follow this  
Morthawt

Website reputation checker (mywot.com)

Recommended Posts

Morthawt

I wanted to see if I could create a program that would essentially do the same as checking the website and pasting in a domain and getting the details without having to actually visit the website, aka using autoit. I have successfully pulled this task off and have even added a colour coding and added commenting to anyone who is trying to understand what is going on and why. Let me know what you think!

#include <String.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$hGUI = GUICreate("Website Reputation & Child Safety Check", 444, 244, -1, -1)
$UserUrl = GUICtrlCreateInput("", 104, 8, 209, 21)
$SiteRep = GUICtrlCreateEdit("", 8, 64, 425, 49, BitOR($ES_READONLY, $WS_BORDER))
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetTip(-1, "Over all site reputation")
$Label1 = GUICtrlCreateLabel("Website URL", 8, 8, 79, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Examples:", 328, 0, 61, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("google.com", 328, 16, 59, 17)
$Label4 = GUICtrlCreateLabel("www.google.com", 328, 32, 86, 17)
$ChildSafety = GUICtrlCreateEdit("", 8, 144, 425, 49, BitOR($ES_READONLY, $WS_BORDER))
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetTip(-1, "Level of child safety regarding site content")
$Label5 = GUICtrlCreateLabel("Over all trustworthiness", 8, 40, 137, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label6 = GUICtrlCreateLabel("Child safety rating", 8, 120, 106, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Go = GUICtrlCreateButton("Check site's reputation", 8, 200, 427, 33, $BS_DEFPUSHBUTTON)
GUICtrlSetTip(-1, "Click to get the reputation of the site you typed.")
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit ; Exit if the X is pressed.

        Case $Go
            If GUICtrlRead($UserUrl) Then ; If the URL entry area has text in it then continue.
                GUICtrlSetState($UserUrl, $GUI_DISABLE) ; Disable the URL entry area.
                GUICtrlSetState($Go, $GUI_DISABLE) ; Disable the button.
                RepCheckURL(GUICtrlRead($UserUrl)) ; Get the contents of the URL entry area and run it through the RepCheckURL function.
                GUICtrlSetState($UserUrl, $GUI_ENABLE) ; Enable the URL entry area
                GUICtrlSetState($Go, $GUI_ENABLE) ; Enable the button.
            EndIf

    EndSwitch
WEnd

Func RepCheckURL($_sURL) ; This function gets run when someone pushes the button and the URL entry area contains text.
    $_sSource = BinaryToString(InetRead('https://www.mywot.com/en/scorecard/' & $_sURL, 1)) ; This downloads the source code of the page that should contain the reputation data for the given site.
    If @error Then ; If there is an error downloading the page then.......
        MsgBox(0, 'There was an error', 'It is likely that you typed the website incorrectly (please read the examples) or the mywot.com website is currently down...')
        Return ; Break out of this function and let the program reset and be ready to use again.
    EndIf

    $_aSplitRating = _StringBetween($_sSource, '<div class="rep-explanation"><p>', '</p>') ; Break the source code up into chunks that are between the two parameters listed.
    Select
        Case Not IsArray($_aSplitRating) ; If $_aSplitRating isn't an array (meaning there was nothing detected that I need) then show the below message box.
            MsgBox(0, 'There was an error', 'Either you typed the website incorrectly (see the examples) or the mywot.com website''s source code has changed meaning this program needs updating.')
            Return ; Break out of this function and let the program reset and be ready to use again.

        Case UBound($_aSplitRating) <> 2 ; If there were chunks of needed data yet there isn't exactly 2 chunks then the source code formatting has been changed and needs to be check into to perhaps fix this script.
            MsgBox(0, 'There was an error', 'The mywot.com website''s source code has changed and this program needs updating.')
            Return ; Break out of this function and let the program reset and be ready to use again.
    EndSelect
    $_aSplitPreConfidence = _StringBetween($_sSource, '<div class="confidence reliability', '></div>') ; Break the source code up into chunks that are between the two parameters listed.
    $_aSplitConfidence0 = _StringBetween($_aSplitPreConfidence[0], 'title="', '"') ; Gets the specific text part of the above chunk for site reputation.
    $_aSplitConfidence1 = _StringBetween($_aSplitPreConfidence[1], 'title="', '"'); Similar to the previous line, this gets the specific text part of the chunk for the child safety level.
    GUICtrlSetData($SiteRep, $_aSplitRating[0] & @CRLF & $_aSplitConfidence0[0]) ; This sets the text in the Site Reputation details box
    GUICtrlSetData($ChildSafety, $_aSplitRating[1] & @CRLF & $_aSplitConfidence1[0]) ; This sets the text in the Child Safety details box
    GUICtrlSetBkColor($SiteRep, '0x' & CheckRepColour($_aSplitRating[0])) ; This changes the background colour of the Reputation details box.
    GUICtrlSetBkColor($ChildSafety, '0x' & CheckRepColour($_aSplitRating[1])) ; This changes the background colour of the Child Safety details box.
EndFunc   ;==>RepCheckURL

Func CheckRepColour($_sInput) ; The text reputation level gets piped into this function to return the correct reputation colour hex code to use as the background of the edit boxes.

    Switch $_sInput
        Case 'Excellent'
            Return '3a6600'

        Case 'Good'
            Return '78bf17'

        Case 'Unsatisfactory'
            Return 'fdbd02'

        Case 'Poor'
            Return 'ff4f2a'

        Case 'Very poor'
            Return 'd91008'

        Case 'Unknown'
            Return 'a1a2a4'
    EndSwitch
EndFunc   ;==>CheckRepColour
Edited by Morthawt

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  

×