VBS 备份百度博客

VBS 备份百度博客

sub denglu ()   '登陆百度,备份私有博客
'on error resume next
do
up = inputbox("请输入用户名和密码" & vbcrlf & "之间以分号 " & chr(34) & ";" & " 隔开",m1)
loop until trim(up) <> "" and len(trim(up)) > 8 and instr(up,";") <> 0
usps = split(trim(up),";")
         ie.visible = false
ie.navigate "http://passport.baidu.com/?login "
Do
Wscript.Sleep 200
Loop Until ie.ReadyState=4
ie.document.getElementById("username").value = usps(0)
ie.document.getElementById("password").value = usps(1)
tj = ie.document.getElementsBytagname("form")
tj.submit
Do
Wscript.Sleep 200
Loop Until ie.ReadyState=4
wscript.sleep 1000
end sub

function isregu(regu,s) '正则表达式判断地址是否合法
'on error resume next
set re = new regexp
re.pattern = regu
sre = re.test(s)
if sre = true then
isregu = true
else
isregu = false
end if
end function

sub bftxt(blogurl) '以TXT格式备份
'on error resume next

ie.visible = 1
ie.navigate blogurl
do until ie.readystate = 4 or ie.buzy
wscript.sleep 200
loop
wscript.sleep 250
text = ie.document.body.innertext
title = ie.document.title
set note = fso.createtextfile(path & "/" & title & ".txt")
note.write text
note.close
end sub

sub bfhtm(blogurl) '以HTML格式备份
'on error resume next
set xh = createobject("Microsoft.XMLHTTP")
xh.Open "GET",blogurl,0
xh.Send()
set ad = createobject("ADODB.Stream")
ad.mode = 3
ad.Type = 1
ad.Open()
ad.Write(xh.responseBody)
ad.savetofile path & "/" & now &".html"


'未完成


ad.SaveToFile path & "/",2
set xh = nothing
set ad = nothing
end sub

'on error resume next
set ws = createobject("wscript.shell")
set fso = createobject("scripting.filesystemobject")
path = ws.currentdirectory
if right(path,1) <> "/" then path = path & "/"
m1 = "VBS百度博客备份工具-by:xiaomingtt"
m2 = "单击"&chr(34)&"是"&chr(34)&"保存为"&chr(34)&"HTML文档"&chr(34)
m3 = "单击"&chr(34)&"否"&chr(34)&"保存为"&chr(34)&"TXT文档"&chr(34)
m4 = "单击"&chr(34)&"取消"&chr(34)&"退出程序"
do
add = inputbox("请输入百度博客地址" & vbcrlf & m4,m1,"http://hi.baidu.com/ ")
if add = "" or add = false then wscript.quit
add = trim(add)
loop until isregu("^http://hi/.baidu/.com/.+$",add) = true
txt = msgbox(m2 & vbcrlf & m3 & vbcrlf & m4,35,m1)
if txt = 2 then wscript.quit
a = msgbox("是否备份私有博客?" & vbcrlf & m4,3+32,m1)
if a = 2 then wscript.quit
fso.createfolder(path & "百度博客")
path = path & "百度博客/" & right(add,len(add) - instrrev(add,"/"))
fso.createfolder(path)
set ie = createobject("internetexplorer.application")
if a = 6 then
call denglu()
do until ie.document.location.href = "http://passport.baidu.com/center " and ie.readystate = 4
wscript.sleep 500
loop
end if
wscript.sleep 500

if right(add,1) <> "/" then add = add & "/"
url = add & "blog/index/0"
urll = url
do
url = urll
ie.navigate url
ie.visible = 1  


do until ie.readystate = 4
wscript.sleep 200
loop
wscript.sleep 500

urlnum = ie.document.links.length
for i = 0 to urlnum - 1
t = ie.document.links(i).innertext
w = ie.document.links(i).href
if t = "下一页" then urll = w
if isregu("^http://hi/.baidu/.com/.*/blog/item/[a-f0-9]{24}/.html$",w) = true and instr(t,"浏览") = 0 then
if txt = 7 then
     uw = uw & w & ","   
end if
if txt = 6 then
     call bfhtm(w)
end if
end if
next
uw = left(uw,len(uw) - 1)
ur = split(uw,",")
for wu = 0 to ubound(ur)
call bftxt(ur(wu))
next
loop until urll = url
msgbox "备份完毕!" & vbcrlf & "文件保存在:" & path,64,m1

### 实现SQL Server 数据库备份VBScript 为了使用 VBScript 备份 SQL Server 数据库,可以通过调用 `sqlcmd` 工具来执行 T-SQL 命令完成此操作。下面展示了一个完整的 ASP 页面示例,该页面不仅包含了 HTML 结构还嵌入了用于启动备份过程的 VBScript 代码。 ```vbscript <%@ Language="VBScript" %> <html> <head> <title>SQL Server Database Backup</title> </head> <body> <% Dim objShell, strBackupCommand, strDatabaseName, strBackupFilePath ' 定义要备份的数据库名称以及目标文件路径 strDatabaseName = "YourDatabase" strBackupFilePath = "C:\Backups\yourdatabase.bak" ' 构建 sqlcmd 的命令字符串 strBackupCommand = "sqlcmd -Q ""BACKUP DATABASE [" & strDatabaseName & "] TO DISK='" & strBackupFilePath & "' WITH INIT""" Set objShell = CreateObject("WScript.Shell") ' 执行备份命令并捕获返回状态码 Dim intReturnCode intReturnCode = objShell.Run(strBackupCommand, 0, True) If intReturnCode = 0 Then Response.Write "成功完成了对 " & strDatabaseName & " 的备份." Else Response.Write "备份过程中发生错误,请检查日志或权限设置." End If ' 清理对象变量 Set objShell = Nothing %> </body> </html> ``` 上述脚本创建了一个名为 `objShell` 的 Windows Script Host Shell 对象实例[^1],并通过其 Run 方法运行由 `strBackupCommand` 变量指定的操作系统级指令。这里使用的具体命令是 `sqlcmd`,它允许从命令行发出 Transact-SQL 查询语句,在这种情况下是用来发起一次新的数据库备份作业。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值