从亚马逊的webclient获取图像

时间:2015-12-22 07:16:55

标签: image browser download amazon webclient

我正在尝试使用以下代码从亚马逊获取图像。它无法下载图像,但如果我使用Internet Explorer,它可以工作。有没有其他方法来模拟IE以确保它获取数据?

    Dim wc As New WebClient()
    wc.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2")
    Dim bytes As Byte() = wc.DownloadData("http://ecx.images-amazon.com/images/I/41NGYbQ1G0L._SS160_.jpg")
    Dim ms As New MemoryStream(bytes)

1 个答案:

答案 0 :(得分:-2)

您可以使用DownloadFile方法。

WebClient.DownloadFile Method (MSDN)