Web Scripts

Web Scripts

1) Count all opened Browsers on desktop, Capture Browser names and
export to an Excel file

Dim oBrowser, Browsers, TotBrowsers, i,r
Set objExcel=CreateObject("Excel.
Application")
Set myFile=objExcel.Workbooks.Open ("C:\Documents and
Settings\Administrator\Desktop\qtclass.xls")
Set mySheet=myFile.Worksheets("Sheet3")
r=1
mysheet.Cells(r,"C")="Browser Names"
Set oBrowser=Description.Create
oBrowser("micclass").value="Browser"

Set Browsers=Desktop.ChildObjects(oBrowser)
TotBrowsers=Browsers.Count
Msgbox TotBrowsers

For i= 0 to TotBrowsers-1 Step 1
       r=r+1
myBrowser=Browsers(i).GetRoproperty("title")
mysheet.Cells(r,"C")=myBrowser
Browsers(i).Close
Next

myFile.Save
objExcel.Quit
Set objExcel=Nothing

2) Check the avilability of Links in the Yahoo Home Page

'Create the object reference link
Set oLink=Description.Create
oLink("micclass").value="Link"

Set Links=Browser("name:=Yahoo! India").Page("title:=Yahoo! India").ChildObjects(oLink)
'Create GoogleSearch sheet to the data table
Datatable.AddSheet "gcreddy"
'Count the total no of links available in Google page
TotLink=Links.Count
'Create file system object and create a text file RegEXP.txt which will be used to hold all the links read from Google page
Set  objFSO=CreateObject("Scripting.FileSystemObject")
objFSO.CreateTextFile("C:\Documents and Settings\bannu\Desktop\gcreddy.txt")
'Open the text file
Set myfile=objFSO.OpenTextFile("C:\Documents and Settings\bannu\Desktop\gcreddy.txt",2)
'Write all links to the text file
For i=0 to TotLink-1

   myLink=Links(i).getROProperty("text")
   myfile.WriteLine myLink
   Next
' Close the text file and release the object reference
   myfile.Close
   Set objFSO=Nothing
'Create another object reference that will be used to read the text file created above
   Set  objFSO1=CreateObject("Scripting.FileSystemObject")
   Set myfile1=objFSO1.OpenTextFile("C:\Documents and Settings\bannu\Desktop\gcreddy.txt",1)

'Read entire content and assign to myRead

myRead=myfile1.ReadAll
'Import datasheet RegExp_Yahoo having the columns as - first column: Link_Name, second column: Result
Datatable.ImportSheet "C:\Documents and Settings\bannu\Desktop\gcreddy.xls", 1, 3
row_count=Datatable.GetSheet(3).GetRowCount
'Create the object reference for Regular expression
Set ObjRegEx=New RegExp
ObjRegEx.IgnoreCase=True
ObjRegEx.Global=True
'For each row within the datatable, assign the first column to the regular exp obj ref, which holds the link name to be searched for
For i = 1 to row_count
Datatable.SetCurrentRow(i)
     ObjRegEx.Pattern=Datatable.Value("LinkNames",3)
set match=objRegEx.Execute(myRead)
If match.Count<>0  Then
Datatable.Value("Results",3)="Link Found"
Else
Datatable.Value("Results",3)="Link Not Found"
End If
Next
     myfile1.Close
Set objFSO1=Nothing
    Set objRegEx=Nothing



0 comments:

Post a Comment