需要检查无效的URL并在output.txt中返回 [英] Need to check invalid URLs and return in output.txt
本文介绍了需要检查无效的URL并在output.txt中返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我在URLs.txt中有1000个链接。我需要自动检查已损坏的链接并返回output.txt中的列表。
我尝试使用批处理文件,但它没有工作。我们可以使用.Net(窗口服务可能)
请帮忙并提供给我代码。
Hi All,
I have 1000 links in URLs.txt.I need to automate to check broken links and return list in output.txt.
I tried using Batch file but its not working thare.Can we do using .Net(Window service may be)
Please help and provide me code.
推荐答案
当我有已经解释了你需要做什么 [ ^ 一>]?并且请不要指望其他人为您找到或编写代码。
Why have you posted this message, when I have already explained what you need to do[^]? And please don''t expect someone else to find or write the code for you.
Hello Nishant,
关注VBScript可以帮到你。
Hello Nishant,
Following VBScript may help you.
Const MODE_READ = 1
Const MODE_WRITE = 2
Dim fso, ts, lin, of, http
Set fso = CreateObject("Scripting. FileSystemObject")
Set ts = fso.OpenTextFile(strInFile, MODE_READ, True)
Set of = fso.CreateTextFile(strOutFile, True, True);
Set http = CreateObject("Microsoft.XmlHttp")
Do While Not ts.AtEndOfStream
lin = ts.ReadLine()
If (!checkUrl(lin)) Then
of.WriteLine(lin)
End If
Loop
ts.Close()
of.Close()
Set fso = Nothing
Function CheckUrl(strUrl)
On Error Resume Next
CheckUrl = True
http.Open "GET", strUrl, False
http.Send ""
If (Err.Number = 0 Or http.status <> 200) Then
CheckUrl = False
End If
End Function
问候,
Regards,
这篇关于需要检查无效的URL并在output.txt中返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文