接下来,我们来学习一下如何成为一名vbs百度助手!
操作方法 01打开计算机,右键单击选择新建文本文档。
建立成功后,桌面上会出现新建文本文档的图标,双击打开。
输入
xz = InputBox( quot;1.我想回答;2.歌曲搜索;3.新闻搜索;" ampChr(13)和amp"4.网络搜索;5.贴出来搜索;6.知道搜索;" ampChr(13)和amp"7.图片搜索;8.视频搜索;9;百科搜索;", quot百度助手[Null _ vbt] quot;, quot")
如果Len(xz)=0,则
MsgBox quot;别无选择,脚本退出!",64, quot错误“
WScript。quit
else
Select Case xz
Case 1
x = URL code(InputBox( quot;请输入您想回答的问题。百度想答“, quot"))
如果Len(x)=0,则
MsgBox quot;未检测到内容,脚本退出!",64, quot错误“
WScript。quit
else
strurl = quot;http://zhidao.baidu.com/q? word = quot; ampx amp" ampct=17岁。pn = 0 ampikaslist amprn=10。lm=65536。fr = answersearch _ 0 quot
End if
Case 2
x = URL code(InputBox( quot;请输入要搜索的歌曲名称。百度歌曲搜索quot, quot;"))
如果Len(x)=0,则
MsgBox quot;未检测到内容,脚本退出!",64, quot错误“
WScript。quit
Else
strurl = quot;http://mp3.baidu.com/m? f = ms amp;baidump3 ampct=134217728。lf = amprn = ampword = quot ampx amp" amplm =-1 quot;
End if
Case 3
x = URL code(InputBox( quot;请输入要搜索的新闻标题。百度新闻搜索quot, quot;"))
如果Len(x)=0,则
MsgBox quot;未检测到内容,脚本退出!",64, quot错误“
WScript。quit
else
strurl = quot;http://news.baidu.com/ns? cl = 2 amp;rn=20。tn =新闻与娱乐。word = quot ampx amp" ampt = 1 quot
End if
Case 4
x = URL code(InputBox( quot;请输入您要搜索的内容。百度网页搜索quot, quot;"))
如果Len(x)=0,则
MsgBox quot;未检测到内容,脚本退出!",64, quot错误“
WScript。quit
else
strurl = quot;http://www.baidu.com/s? cl = 3 amp;wd = quot ampx
End if
Case 5
x = URL code(InputBox( quot;请输入文章标题进行搜索。百度贴吧搜索“, quot"))
如果Len(x)=0,则
MsgBox quot;未检测到内容,脚本退出!",64, quot错误“
WScript。quit
else
strurl = quot;http://tieba.baidu.com/f? kw = quot; ampx
End if
Case 6
x = InputBox( quot;请输入要搜索的已知标题。知道百度搜索”, quot")
如果Len(x)=0,则
MsgBox quot;未检测到内容,脚本退出!",64, quot错误“
WScript。quit
else
strurl = quot;http://zhidao.baidu.com/q? CT = 17 amp;pn = 0 ampikaslist amprn=10。word = quot ampx
End if
Case 7
x = URL code(InputBox( quot;请输入您要搜索的图片的标题。百度图片搜索quot, quot;"))
如果Len(x)=0,则
MsgBox quot;未检测到内容,脚本退出!",64, quot错误“
WScript。quit
else
strurl = quot;http://image.baidu.com/i? TN = baiduimage amp;ct = 201326592 amplm =-1 amp;cl = 2 ampword = quot ampx amp" ampt = 3 quot
End if
Case 8
x = URL code(InputBox( quot;请输入要搜索的视频标题“, quot百度视频搜索quot, quot;"))
如果Len(x)=0,则
MsgBox quot;未检测到内容,脚本退出!",64, quot错误“
WScript。quit
else
strurl = quot;http://video.baidu.com/v? CT = 301989888。rn=20。pn = 0 ampdb = 0 amps = 7 ampword = quot ampx
End if
Case 9
x = URL code(InputBox( quot;请输入百科全书的标题进行搜索”, quot百度搜索“, quot"))
如果Len(x)=0,则
MsgBox quot;未检测到内容,脚本退出!",64, quot错误“
WScript。quit
else
strurl = quot;http://baike.baidu.com/w? CT = 17 amp;lm = 0 ampbaiduWikiSearch amppn = 0 amprn=10。word = quot ampx
End if
End Select
End if
Set objIe = CreateObject( quot;InternetExplorer。申请 quot)
objIe . visible = true
objIe。将strUrl
函数Urlcode(InpStr)
Dim InpAsc,I
For I = 1导航到Len(InpStr)
InpAsc = Asc(Mid(InpStr,I,1))
If((InpAsc lt;58)和(InpAsc gt47))或((InpAsc lt91)和(InpAsc gt64))或((InpAsc lt123)和(InpAsc gt96))那么
URL code = URL code amp;chr(InpAsc)
Else
Urlcode = Urlcode amp;"% quot ampmid(Trim(Hex(InpAsc)),1,2)和amp"% quot ampmid(Trim(Hex(InpAsc)),3,2)
End If
Next
End函数
输入完毕后,点击左上角的另存为,将文件名的后缀改为vbs,点击保存。
就是这样,成功制作后桌面会显示一个文件名为“新建文本文档”的文件。vbs”出现在桌面上,这是我们的百度助手。
双击打开,如下图所示。