编程方式登录到亚马逊用C# [英] Programatically login to Amazon with C#

查看:688
本文介绍了编程方式登录到亚马逊用C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要登录到亚马逊卖家用C#编程中心。我不希望使用亚马逊Web服务

I want to login to Amazon seller central programatically with C#. I don't want to use Amazon Web Services.

下面是我迄今所做的:

private void button1_Click(object sender, EventArgs e)
{
    string appURL = "https://sellercentral.amazon.com/gp/sign-in/sign-in.html/ref=xx_login_lgin_home";
    string strPostData = "protocol=https&action=sign-in&email=test%40gmail.com&destination=https%3A%2F%2Fsellercentral.amazon.com%2Fgp%2Fhomepage.html%3Fie%3DUTF8%26%252AVersion%252A%3D1%26%252Aentries%252A%3D0&optin=1&ouid=01&password=ntest&sign-in-button=&metadata1=SIsVVcIUMA1uElSK%2BySsVuCX1YuhcTji35ShGdQ%2Fd4ipBgkh6qW6HcPfyVu4dbOFdZiErWz%2F9OumR%2FfeVnrNSUUSEkIokrMPxYFPtZTlfJc44D8hWHpewjOs5TF4NIDyehvkc5eHJ8GsDbiUSdBtOq4iBnIpkIpAodIzIVFHK%2FQJJICA9n%2F8abB4XfwODJrI7YSa1gwCMrJbh0wvpAW5%2B%2BHecdjA5Bin8slkBqj9LQG%2FfSrTXlAGPsW21qV2ba4kej5xdjytVTELVqnLPB9Fc1Z%2FR98qDpBkQ%2F2lM3EV4POoe0nsAMALomqvOhOkIInqp14Ic%2BxJU35hX89rIhmSQMpL1WtMGE%2F9A2ebmHV%2BzlW0tUZIfxyupg2MiNJIeg1uNqBhBT8duYyKp0n3d5gYOnhxYCQTqR297AV%2FDAdHSlbrJRT5HX9spg9RyHSTDLiGvhy1BaK0LIzvR%2Bj786i4Z%2FCGBpb31XcXrFx9uDe8rxtNRLFiDXqxUCCf8hTBEhtyYriB2%2FlZAvoIRyAZMLDYykncALiRVPOWkQX%2FQjZUu6M6bBfqaQ6ODQlbc0j9V2FZ%2BEQng456mQmUOoO5";

    // Setup the HTTP request.
    HttpWebRequest objWebRequest = (HttpWebRequest)WebRequest.Create(appURL);
    objWebRequest.Method = "POST";
    objWebRequest.AllowAutoRedirect = true;
    objWebRequest.CookieContainer = new CookieContainer(); //Enable Coolkie
    objWebRequest.ContentLength = strPostData.Length;
    objWebRequest.ContentType = "application/x-www-form-urlencoded";
    objWebRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)";

    // Post to the login form.
    StreamWriter swRequestWriter = new
        StreamWriter(objWebRequest.GetRequestStream());
    swRequestWriter.Write(strPostData);
    swRequestWriter.Close();

    // Get the response.
    HttpWebResponse objWebResponse =
        (HttpWebResponse)objWebRequest.GetResponse();

    // Read the response
    StreamReader srResponseReader = new
        StreamReader(objWebResponse.GetResponseStream());
    string strResponseData = srResponseReader.ReadToEnd();
    srResponseReader.Close();

    // Display the response.
    webBrowser1.DocumentText = strResponseData;
}



}

}

当我执行它,我得到一个答复登录页面,不登录,为什么?我做错了什么?我用它来显示HTML响应Web浏览器。

When i execute it I get as a response the login page and don't login... Why? What I am doing wrong? I use to display the html response a web browser.

我的目标是登陆,然后在中央卖家搜索到一些产品在我的库存。如何做到这一点,并保持对其他webrequests我会做会议和饼干?

My goal is to login and then search some products in my inventory in seller central. How to do this and keep sessions and cookies on other webrequests i will do?

推荐答案

他们[亚马逊]有无数的Javascript页。这些脚本的全部目的似乎是阻止人们做你正在尝试做的。

They [Amazon] have numerous Javascripts on the page. The whole purpose of these scripts seems to be to prevent people doing what you are trying to do.

在处理表单数据和调用其它各种页面资产。亚马逊然后使用这些其他资产调用和操纵的数据,以确定是否该请求是从一个合法的浏览器或东西试图仿效一个浏览器。

The manipulate the form data and call various other page assets. Amazon then use those other assets calls and the manipulated data to determine if the request is from a legitimate browser or something trying to emulate a browser.

这是一个安全措施以停止卖家账户能够蛮力攻击黑客等

It's a security measure to stop seller accounts being capable of a brute-force hack attack, etc.

JS片段是故意混淆,以防止你轻松地逆向工程他们,当然,没有什么是不可能的当你运用知识,耐心和韧劲。

The JS snippets are purposefully obfuscated to prevent you from easily reverse engineering them, but of course nothing is impossible when you apply knowledge, patience and tenacity.

如果你想追求这个话,我会建议逆向工程的JS在页面上,然后模仿什么这些作品如果代码做与表单值等也效仿其他资产的呼叫,相对定时流沿。注意是偷偷的图像或远程脚本头设置cookie,并确保您的脚本始终表现正常的饼干罐。

If you want to pursue this then I would recommend reverse engineering the JS on the page and then emulate what those pieces if code do with the form values, etc. and also emulate the other asset calls, along with relative timing flow. Pay attention to cookies being secretly set in image or remote script headers, and ensure your cookie jar for your script is always behaving properly.

这些反仿真技术是经常使用防止僵尸网络从PPC网络模拟点击。他们是骗不了的证据,也不是牢不可破的,但它会带你相当长的时间来得到它的工作。

These anti-emulation techniques are used regularly to prevent bot networks from emulating clicks on PPC networks. They are not fool proof nor are they unbreakable, but it will take you considerable time to get it working.

老实说,如果你不愉快的编程风格或功能C#库所提供,那么你可能是最好建立自己的图书馆,利用亚马逊商城网络服务。

Honestly, if your not happy with the programming styles or functionality of C# libraries they provide, then you may be best building your own library to utilise the Amazon Marketplace Web Services.

在长远来看,你将有一个更加稳​​定的工具包这不会需要定期更新。

In the long run you'll have a much more stable toolkit that wont need updating regularly.

这篇关于编程方式登录到亚马逊用C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆