Re: Automating search for words in a website using WSH
- From: "Hii Sing Chung" <singchung@xxxxxxxxxxx>
- Date: Mon, 8 Jun 2009 19:14:23 +0800
Just wonder,
Is there a way to bold some texts of the e-mail body through the script? I want to bold the "IT Control Unit - Security" at the beginning of the message body.
Thanks.
"Paul Randall" <paulr901@xxxxxxxxxxxx> wrote in message news:etabz265JHA.936@xxxxxxxxxxxxxxxxxxxxxxx
Hi,.
I've pasted in some code to automate IE to do part of what you need to get your information. It finds five DIV elements with <DIV class=article>, displays them and writes them to files named 'Div n.htm', where n is one to five. This allows you to look at them easily in IE and tell whether one or more of them contain information you require. I realize they may not display perfectly because they don't contain header info that "http://www.rbl.jp/phishing/" provided to ensure correct display. You might look at them using the free version of PSPad, and use its built-in HTML Tidy tool to make it easier to see the details of these division elements. Then it should be easy to figure out how to extract the items you want to count.
Option Explicit
Dim oIE 'Internet Explorer Object
' Documentation at: http://msdn.microsoft.com/en-us/library/aa752084.aspx
Set oIE = WScript.CreateObject("InternetExplorer.Application")
oIE.Navigate "http://www.rbl.jp/phishing/"
oIE.ToolBar = 0
oIE.StatusBar = 0
oIE.Width=300
oIE.Height = 150
oIE.Left = 0
oIE.Top = 0
oIE.Visible = True
Do While oIE.Busy: WScript.Sleep 20: Loop
MsgBox "Done loading web page"
Dim oIEDoc 'IE Document Object; gives access to
' Document Object Model (DOM) of the loaded web page.
'Documentation at:
' http://msdn.microsoft.com/en-us/library/ms533050(loband).aspx
Set oIEDoc = oIE.Document
MsgBox "Total number of tags = " & oIEDoc.All.length & vbCrLf & _
"Total number of 'div' tags = " & oIEDoc.All.Tags("div").length
Dim oTag, oAttribute, sMsg, iCount
For Each oTag In oIEDoc.All.Tags("div")
' look for 'article' within the <div ... > portion of the element.
If InStr(Left(oTag.OuterHtml, InStr(oTag.OuterHtml, ">")), _
"article") Then
iCount = iCount + 1
MsgBox oTag.OuterHtml
fOverWriteAU "Div" & " " & iCount & ".htm", otag.outerhtml
End If
' End If
Next 'oTag
Sub fOverWriteAU(sFilePath, sText)
On Error Resume Next
CreateObject("Scripting.FileSystemObject")._
CreateTextFile(sFilePath, True, False)._
Write(sText)
If Err Then
CreateObject("Scripting.FileSystemObject")._
CreateTextFile(sFilePath, True, True)._
Write(sText)
End if
End Sub 'fOverWriteAU(sFilePath, sText)
-Paul Randall
"Hii Sing Chung" <singchung@xxxxxxxxxxx> wrote in message news:2A45432B-BEFA-4994-88B2-F7F2814631C7@xxxxxxxxxxxxxxxxTim,
Thanks. I need to read up more to understand your explanations. Here is the content of my WSH, I haven't put in the automation of iexplorer and the subsequent searching action. I will need to get the value of intCount:
option explicit
on error resume next
dim objEmail, objWshShell, objOutlook, objWshNetwork
dim strTo, strCc, strText, strDate, strIncrease, strMessage, intCount, strUsername
Const conMailItem = 0
strDate = formatdatetime (date, vblongdate)
Set objOutlook = createobject("Outlook.Application")
Set objEmail = objOutlook.createitem(conMailItem)
set objWshShell = wscript.createobject ("wscript.shell")
set objWshNetwork = CreateObject("WScript.Network")
strUsername = objWshNetwork.username
strTo = "DataCenter_Supervisor; DataCenter_Singapore_Supervisor"
strCc = "Security_Operator"
IntCount = 0
If intCount = 0 Then
strIncrease = "no"
else
strIncrease = intCount
end if
objEmail.To = strTo
objEmail.Cc = strCc
objEmail.Subject = "Report mail for the phishing site check on " & strDate
strMessage = "IT Control Unit-Security, " & vbcrlf & vbcrlf &_
"The number of phishing site is as below:" & vbcrlf & vbcrlf &_
"[" &IntCount&"]" & vbcrlf & vbcrlf & "There is " & strIncrease & " increase." &_
vbcrlf & vbcrlf & vbcrlf & vbcrlf & "The helpful sites are below:" &vbcrlf &_
"http://www.rbl.jp/phishing/" & vbcrlf & "http://www.fraudwatchinternational.com/phishing/search.php" & vbcrlf &_
"Thanks and Regards," & vbcrlf & strUsername & vbcrlf & "ex. 25332" & vbcrlf & "IT Security Monitoring"
objEmail.body = strMessage
objEmail.display
objEmail.send
wscript.quit
"Tim Harig" <usernet@xxxxxxxxxx> wrote in message news:IZEWl.8892$Lr6.408@xxxxxxxxxxxxxxxxxxxxxxxOn 2009-06-07, Hii Sing Chung <singchung@xxxxxxxxxxx> wrote:Tim,
1. http://www.rbl.jp/phishing/ At this website, we will look under today's
posting at the top portion (June 6, 2009) for the presence of the
organization's names in any forms. If we see any match, we will count the
number of occurrences.
This should be extremely easy to parse. Note that all of the date
information in contained within <div class="article"></div>. So, all you
have to do is getElementByTagName("div") and run through the results until
you get the ones which have the properties nodeName=class and
nodeValue=article.
The date is then underneath with an <h3> tag. You run through the
article divs until you find the date that you are looking for; then, the
information is all under the <div class="dan"></div>. It couldn't get much
easier. You just grab the organization names and calculate them as you
please.
2. http://www.fraudwatchinternational.com/phishing/search.php At this page
we will select today's date, then select the organization name from the drop
down 'target company', then click search. The result will be displayed as
"Result Found: [number of occurrence]".
The number of occurrence we will added up from these 2 sites and key in the
e-mail as number of increase in phishing detected.
Let me try to get my team member to furnish an example of the e-mail.
This one is just as easy. All of the information is under a form with an
id so you just have to getElementByTagName("form") and check the results
until you get the one with id="alertsearch". The underlying fields can be
identified by their name and then set by changing their value attribute.
Once the form is filled in, you just grab the button and fire its onclick
event which will submit the information to th server.
All and all these are very simple pages to use because of all the context
data stored within the class attributes. I have worked with *MUCH* worse.
It shouldn't be much trouble to automate.
- Follow-Ups:
- Re: Automating search for words in a website using WSH
- From: Paul Randall
- Re: Automating search for words in a website using WSH
- References:
- Automating search for words in a website using WSH
- From: Hii Sing Chung
- Re: Automating search for words in a website using WSH
- From: Tim Harig
- Re: Automating search for words in a website using WSH
- From: Hii Sing Chung
- Re: Automating search for words in a website using WSH
- From: Tim Harig
- Re: Automating search for words in a website using WSH
- From: Hii Sing Chung
- Re: Automating search for words in a website using WSH
- From: Tim Harig
- Re: Automating search for words in a website using WSH
- From: Hii Sing Chung
- Re: Automating search for words in a website using WSH
- From: Paul Randall
- Automating search for words in a website using WSH
- Prev by Date: Re: Automating search for words in a website using WSH
- Next by Date: Re: Automating search for words in a website using WSH
- Previous by thread: Re: Automating search for words in a website using WSH
- Next by thread: Re: Automating search for words in a website using WSH
- Index(es):
Relevant Pages
|