带重定向的chilkat ActiveX HTTP组件的问题
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了带重定向的chilkat ActiveX HTTP组件的问题相关的知识,希望对你有一定的参考价值。
我使用此脚本检查了最后一个重定向URL:
set http = CreateObject("Chilkat_9_5_0.Http")
http.FollowRedirects = 0
' resp is a Chilkat_9_5_0.HttpResponse
Set resp = http.QuickGetObj(link)
If (http.LastMethodSuccess = 0) Then
wscript.echo http.LastErrorText
WScript.Quit
End If
status = resp.StatusCode
wscript.echo "HTTP Response Status: " & status
wscript.echo "Redirect URL >>>: " & http.FinalRedirectUrl
nextUrl = http.WasRedirected
loopCount = 0
Do While (status = 302 OR status = 301)
wscript.echo "HTTP Response Status: " & status
wscript.echo "Redirect URL >>>: " & http.FinalRedirectUrl
nextUrl = http.FinalRedirectUrl
' resp is a Chilkat_9_5_0.HttpResponse
Set resp = http.QuickGetObj(nextUrl)
If (http.LastMethodSuccess = 0) Then
wscript.echo http.LastErrorText
WScript.Quit
End If
status = resp.StatusCode
wscript.echo "HTTP Response Status: " & status
' For safety, prevent infinite loops by
' keeping a loopCount and only allows following a max
' of 10 redirects:
loopCount = loopCount + 1
If (loopCount > 10) Then
wscript.echo "Too many redirects."
WScript.Quit
End If
Loop
此代码可正确打印301状态代码,但不会打印http.FinalRedirectURL(空白)。
我也尝试使用网址https://www.businessonline.it/articoli/guida-al-nuovo-regime-forfettario-2016-e-2017.html
输出为:
Link: https://www.businessonline.it/articoli/guida-al-nuovo-regime-forfettario-2016-e-2017.html
HTTP Response Status: 301
Redirect URL >>>:
HTTP Response Status: 301
Redirect URL >>>:
ChilkatLog:
QuickGetObj:
DllDate: Oct 28 2019
ChilkatVersion: 9.5.0.80
UnlockPrefix: BRKEVN.XXXXXXXXXXX
Architecture: Little Endian; 32-bit
Language: ActiveX
VerboseLogging: 0
Component successfully unlocked using purchased unlock code.
url:
verb: GET
quickRequestDb:
url:
getHttpConnectionByUrl:
urlObject_loadUrl:
No domain in URL
url:
--urlObject_loadUrl
--getHttpConnectionByUrl
--quickRequestDb
Failed.
--QuickGetObj
--ChilkatLog
我同时使用了chilkat 9.5.0.70和9.5.0.80。如果我将FollowRedirects设置为1,则第一个StatusCode是“ 200”,但我无法获取该网址。
你能帮我吗?
谢谢
答案
感谢洛伦佐,
问题与QuickGetObj和QuickGet有关。 QuickGetStr方法对于WasRedirected和FinalRedirectUrl属性的效果很好。
这里是带有修复的新的32位ActiveX构建:
32位:https://chilkatdownload.com/prerelease/chilkatax-9.5.0-win32-1630.zip
以上是关于带重定向的chilkat ActiveX HTTP组件的问题的主要内容,如果未能解决你的问题,请参考以下文章
Google Analytics - 带重定向的出站链接跟踪
使用 Chilkat 和 SQL Server 将单个电子邮件附件保存到 BLOB