skip to Main Content

I have an affiliate account with Amazon and have been collecting information from the Amazon site for the purpose of sending them buyers. Today, I tested my site and found that all of the requests to Amazon failed. Here is the evidence:

  1. I am using ASP.NET (VB) HttpWebRequest to gather the data. Provide it a URL, then use HttpWebResponse / GetResponseStream to retrieve the page.
  2. Most of my Amazon data I get from the Amazon API (AWSECommerceService) – that service still works. Some data is not available from the API, which is why I resort to scraping.
  3. As of today, any HttpWebRequest to any page on Amazon (even the home page) returns a 503 (Server Unavailable) exception. Those pages are all visible in any browser.
  4. Every other Web site that I access still works (eBay, Barnes & Noble, etc.), so the problem is only with Amazon.

Postulate: Amazon has programmed its
Web site to reject automated
inquiries.
Is there any way to spoof
the system and convince Amazon to send
the page?
Thanks and kudos to anyone who can shed some light!

NOTE: in researching the problem, I saw a suggestion to add a UserAgent parameter to the HttpWebRequest. I tried using a UserAgent code for IE8, but it made no difference. (UserAgent code found at http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.useragent.aspx)

3

Answers


  1. I’ve experienced exactly the same problem starting two days ago.

    I’ve been using HttpWebRequest for years without any problems and also adding the Useragent parameter makes no difference.

    The only solution I can come up with at present is to use a windows form with embedded webbrowser with some code like the following:-

    Sub GetHTML
    
     WebBrowser1.Navigate("http://www.amazon.co.uk")
    
    Application.DoEvents()
    
    End Sub
    
    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
    
        Dim oDoc1
        Dim StrHTML As String
    
        oDoc1 = WebBrowser1.Document
        StrHTML = oDoc1.body.outerhtml
    End Sub
    
    Login or Signup to reply.
  2. Try setting the UserAgent for the HTTPWebRequet before you make the call

    Login or Signup to reply.
  3. After some further testing, it turns out that this was happening because Amazon needs the Accept parameter of the HttpWebRequest to be specifically set.
    Just set it to:

    request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search