我可以使用一些不符合預期的vbscript代碼的幫助。我騎自行車通過幾個網絡圖像網址,看看它們是否有效,並發現一些返回不正確的HTTP返回代碼,如下所示。使用MSXML2.ServerXMLHTTP.6.0返回錯誤的HTTP代碼
'these urls return code 403 but they are valid image urls
url = "https://www.skymedia.co.uk/wp-content/uploads/2016/05/Sky-Sports-Mix.png"
'url = "https://www.skymedia.ie/wp-content/uploads/sites/4/2016/01/channel-logo-tlc.png"
'this url returns code 403 which is correct
'url = "http://www.lyngsat-logo.com/hires/aa/astro_supersport_my.png"
'this url returns code 200 which is correct
'url = "http://cdn.cablefax.com/wp-content/uploads/2014/06/golf-logo.jpg"
Set req = CreateObject("MSXML2.ServerXMLHTTP.6.0")
req.open "GET", url, False
req.send
'check http status codes
If req.Status = 200 Then httpCode = "HTTP 200 OK - "
If req.Status = 400 Then httpCode = "HTTP 400 Bad Request - "
If req.Status = 403 Then httpCode = "HTTP 403 Forbidden - "
If req.Status = 404 Then httpCode = "HTTP 404 Not Found - "
WScript.Echo httpCode & url
任何幫助解決這個謎是非常感謝。 -Al
*它可能是有益的告訴發生了什麼,以及與預期有什麼不同。 –