Rem Type=Plugin
Rem Name= wiki super scraper
Rem Author= cyberjedi
Rem Host=All
Rem PLUGIN: PRE-PROCESS
'The preceding comment is actually a plug-in directive for
'the Ultra Hal host application. It allows for code snippets
'to be inserted here on-the-fly based on user configuration.
HalBrain.ReadOnlyMode = True
'Determines that you are talking about cybersearch.
If InStr(1,InputString, "cybersearch",1) > 0 Then
UltraHal = cybersearch(HalCommands)
ElseIf InStr(1,InputString, "cybersearch",1) > 0 Then
End If
Rem PLUGIN: FUNCTIONS
Function cybersearch (HalCommands)
'The Cyber Super Scraper : This monster Scrapes Wikipedia and reads aloud the answers. All ported through Hal
'A separate window will pop up for input.
' For those who think Hals Plugin language is weak:
'I hope u guys can enjoy this as Much as me.
' I supplied the raw source do as u Please. for any questions , i can be reached here
http://vaughnlive.tv/mrelectric ' For plugin, save as .uhp
'You will get a popup window that i left in the plugin. because of running into Multi-Choice output in Wiki.
' In private i call this the Beast from the East
' i havent narrated it, just dont have the energy today, maby soon. pretty clear what it is.
' This is a solid 9.9 on the wierdshiztometer.
'Best wishes
'cyberjedi aka The no fuq around crew
'*********************************
On Error Resume Next
Const SVSFlagsAsync = 1
Set Sapi = CreateObject("SAPI.SpVoice")
For Each Voice In Sapi.GetVoices
i = i + 1
Next
For loopvar = 0 to i-1
if loopvar = CInt(confirm_voice) then
Set Sapi.Voice = Sapi.GetVoices.Item(loopvar)
end if
Next
Dim oDoc1 , oDoc2 , oDoc3 ,oDoc4 , con1 , con2 , con3
Set oDoc1 = CreateObject("HTMLFile")
Set oDoc2 = CreateObject("HTMLFile")
Set oDoc3 = CreateObject("HTMLFile")
Set oDoc4 = CreateObject("HTMLFile")
Set con1 = CreateObject("MSXML2.ServerXMLHTTP.6.0")
Set con2 = CreateObject("MSXML2.ServerXMLHTTP.6.0")
Set con3 = CreateObject("MSXML2.ServerXMLHTTP.6.0")
Set WshShell = CreateObject("Wscript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")
HalMenu.HalCommand "<SPEAK>" &"Enter keyword to do a Cyber search " , SVSFlagsAsync & "</SPEAK>"
URL1 = "
https://en.wikipedia.org/w/index.php?title=Special:Search&search="
Keyword = InputBox("Cyberjedi search ","Cyberjedi Voice Search") '<<<<<< this can be ported to Hals window: I like it as is
If Keyword = "" then
wscript.Quit
Else
HalMenu.HalCommand "<SPEAK>" & "Please Wait ." & "</SPEAK>"
end if
tempURL1 = URL1 & Keyword & "&fulltext=Search&profile=default"
con1.Open "GET", tempURL1 , False
con1.Send
oDoc1.Write con1.responseText
if oDoc1.GetElementsByTagName("b")(0) is nothing then
'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
tempTxt1 = oDoc1.GetElementsByTagName("div")(17).InnerText
if tempTxt1 = "" then
'B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3
HalMenu.HalCommand "<SPEAK>" & "Sorry your entered keyword does not match any titles of articles . Check the spelling ." & "</SPEAK>"
'B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3B3
else
Select Case tempTxt1
Case "Did you mean: " & oDoc1.GetElementsByTagName("a")(8).InnerText
'B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1
HalMenu.HalCommand "<SPEAK>" & "Sorry for the inconvenience caused , but this minor part of the program is under development ." & "</SPEAK>"
'B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1B1
Case "Showing results for " & oDoc1.GetElementsByTagName("a")(8).InnerText & ". Search instead for " & Keyword & "."
'B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2
HalMenu.HalCommand "<SPEAK>" & "Showing results for " & oDoc1.GetElementsByTagName("a")(8).InnerText , SVSFlagsAsync & "</SPEAK>"
HalMenu.HalCommand "<SPEAK>" & "Please wait , while that opens ." , SVSFlagsAsync & "</SPEAK>"
tempTxt1 = oDoc1.GetElementsByTagName("a")(12).href
tempTxt2 = Right(tempTxt1, Len(tempTxt1) - 6)
URL2 = "
https://en.wikipedia.org" & tempTxt2
con2.Open "GET", URL2 , False
con2.Send
oDoc2.Write con2.responseText
temptemp = Right(oDoc2.GetElementsByTagName("p")(0).InnerText , 13)
if temptemp = "may refer to:" then
HalMenu.HalCommand "<SPEAK>" & "This specific keyword , has many references ." & "</SPEAK>"
HalMenu.HalCommand "<SPEAK>" & "Select the correct choice ." & "</SPEAK>"
tempLen1 = oDoc2.GetElementsByTagName("li").length - 3
val = 0
For loopvar = 0 to tempLen1
if oDoc2.GetElementsByTagName("li")(loopvar).InnerText = "Disambiguation pages" then
Exit For
end if
if val > 2 then
HalMenu.HalCommand "<SPEAK>" & "Is this ?" , SVSFlagsAsync & "</SPEAK>"
else
HalMenu.HalCommand "<SPEAK>" & "Is this the article you are searching for ?" , SVSFlagsAsync & "</SPEAK>"
end if
tempTxt3 = MsgBox (oDoc2.GetElementsByTagName("li")(loopvar).InnerText, vbYesNo + vbQuestion, "Is this the article you are searching for ?")
Select Case tempTxt3
Case vbYes
HalMenu.HalCommand "<SPEAK>" & "Please wait , while that opens ." , SVSFlagsAsync & "</SPEAK>"
tempTxt4 = oDoc2.GetElementsByTagName("li")(loopvar).InnerHtml
oDoc4.write tempTxt4
tempTxt5 = oDoc4.getElementsByTagName("a")(0).href
tempTxt6 = Right(tempTxt5, Len(tempTxt5) - 6)
URL3 = "
https://en.wikipedia.org" & tempTxt6
con3.Open "GET", URL3 , False
con3.Send
oDoc3.Write con3.responseText
HalMenu.HalCommand "<SPEAK>" & oDoc3.GetElementsByTagName("p")(0).InnerText & "</SPEAK>"
if oDoc3.GetElementsByTagName("p")(1) is nothing then
wscript.Quit
else
HalMenu.HalCommand "<SPEAK>" & oDoc3.GetElementsByTagName("p")(1).InnerText & "</SPEAK>"
end if
wscript.Quit
Case vbNo
val = val + 1
End Select
Next
HalMenu.HalCommand "<SPEAK>" & "Sorry your entered keyword does not match any titles of articles . Check the spelling ." & "</SPEAK>"
wscript.Quit
else
tempTxt1 = oDoc1.GetElementsByTagName("a")(8).href
tempTxt2 = Right(tempTxt1, Len(tempTxt1) - 6)
URL2 = "
https://en.wikipedia.org" & tempTxt2
con2.Open "GET", URL2 , False
con2.Send
oDoc2.Write con2.responseText
HalMenu.HalCommand "<SPEAK>" & oDoc2.GetElementsByTagName("p")(0).InnerText & "</SPEAK>"
if oDoc2.GetElementsByTagName("p")(1) is nothing then
wscript.Quit
else
HalMenu.HalCommand "<SPEAK>" & oDoc2.GetElementsByTagName("p")(1).InnerText & "</SPEAK>"
end if
wscript.Quit
end if
'B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2
End Select
'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
end if
else
HalMenu.HalCommand "<SPEAK>" & oDoc1.GetElementsByTagName("b")(0).InnerText , SVSFlagsAsync & "</SPEAK>"
HalMenu.HalCommand "<SPEAK>" & "Please wait , while that opens ." , SVSFlagsAsync & "</SPEAK>"
tempTxt1 = oDoc1.GetElementsByTagName("a")(8).href
tempTxt2 = Right(tempTxt1, Len(tempTxt1) - 6)
URL2 = "
https://en.wikipedia.org" & tempTxt2
con2.Open "GET", URL2 , False
con2.Send
oDoc2.Write con2.responseText
temptemp = Right(oDoc2.GetElementsByTagName("p")(0).InnerText , 13)
if temptemp = "may refer to:" then
'A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1
HalMenu.HalCommand "<SPEAK>" & "This specific keyword , has many refernces ." & "</SPEAK>"
HalMenu.HalCommand "<SPEAK>" & "Select the correct choice ." & "</SPEAK>"
tempLen1 = oDoc2.GetElementsByTagName("li").length - 3
val = 0
For loopvar = 0 to tempLen1
if oDoc2.GetElementsByTagName("li")(loopvar).InnerText = "Disambiguation pages" then
Exit For
end if
if val > 2 then
HalMenu.HalCommand "<SPEAK>" & "Is this ?" , SVSFlagsAsync & "</SPEAK>"
else
HalMenu.HalCommand "<SPEAK>" & "Is this the article you are searching for ?" , SVSFlagsAsync & "</SPEAK>"
end if
tempTxt3 = MsgBox (oDoc2.GetElementsByTagName("li")(loopvar).InnerText, vbYesNo + vbQuestion, "Is this the article you are searching for ?")
Select Case tempTxt3
Case vbYes
HalMenu.HalCommand "<SPEAK>" & "Please wait , while that opens ." , SVSFlagsAsync & "</SPEAK>"
tempTxt4 = oDoc2.GetElementsByTagName("li")(loopvar).InnerHtml
oDoc4.write tempTxt4
tempTxt5 = oDoc4.getElementsByTagName("a")(0).href
tempTxt6 = Right(tempTxt5, Len(tempTxt5) - 6)
URL3 = "
https://en.wikipedia.org" & tempTxt6
con3.Open "GET", URL3 , False
con3.Send
oDoc3.Write con3.responseText
HalMenu.HalCommand "<SPEAK>" & oDoc3.GetElementsByTagName("p")(0).InnerText & "</SPEAK>"
if oDoc3.GetElementsByTagName("p")(1) is nothing then
wscript.Quit
else
HalMenu.HalCommand "<SPEAK>" & oDoc3.GetElementsByTagName("p")(1).InnerText & "</SPEAK>"
end if
wscript.Quit
Case vbNo
val = val + 1
End Select
Next
HalMenu.HalCommand "<SPEAK>" & "Sorry your entered keyword does not match any titles of articles . Check the spelling ." & "</SPEAK>"
wscript.Quit
'A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1A1
else
'A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2
tempTxt1 = oDoc1.GetElementsByTagName("a")(8).href
tempTxt2 = Right(tempTxt1, Len(tempTxt1) - 6)
URL2 = "
https://en.wikipedia.org" & tempTxt2
con2.Open "GET", URL2 , False
con2.Send
oDoc2.Write con2.responseText
HalMenu.HalCommand "<SPEAK>" & oDoc2.GetElementsByTagName("p")(0).InnerText & "</SPEAK>"
if oDoc2.GetElementsByTagName("p")(1).InnerText = "" then
wscript.Quit
else
HalMenu.HalCommand "<SPEAK>" & oDoc2.GetElementsByTagName("p")(1).InnerText & "</SPEAK>"
end if
wscript.Quit
'A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2A2
end if
end if
End Function