示例#1
0
        /// <summary>The entry point for the application.</summary>
        /// <param name="argv">A list of arguments</param>
        public static void Main(string[] argv)
        {
            bool parseCommandLineArguments;
            AmazonSearchArgument amazonSearchArgument = new AmazonSearchArgument();

            parseCommandLineArguments = Parser.ParseArgumentsWithUsage(argv, amazonSearchArgument);
            if (parseCommandLineArguments == false)
            {
                return;
            }
            KeywordSearchRequestStub(amazonSearchArgument);
        }
示例#2
0
        public static void KeywordSearchRequestStub(AmazonSearchArgument amazonSearchArgument)
        {
            KeywordRequest keywordRequest = new KeywordRequest();

            if (string.IsNullOrEmpty(amazonSearchArgument.AccessKeyID))
            {
                amazonSearchArgument.AccessKeyID = AccessKeyID;
            }

            System.Console.WriteLine(amazonSearchArgument);

            keywordRequest.devtag  = amazonSearchArgument.AccessKeyID;
            keywordRequest.keyword = amazonSearchArgument.Keyword;
            keywordRequest.locale  = amazonSearchArgument.Locale;
            keywordRequest.mode    = amazonSearchArgument.Mode;
            keywordRequest.page    = amazonSearchArgument.Page;
            keywordRequest.sort    = amazonSearchArgument.Sort;
            //keywordRequest.tag
            keywordRequest.type = amazonSearchArgument.Type;

            return;

            using (AmazonSearchService amazonSearchService = new AmazonSearchService())
            {
                try
                {
                    ProductInfo productInfo = amazonSearchService.KeywordSearchRequest(keywordRequest);
                    if (productInfo.Details.Length > 0)
                    {
                        System.Console.WriteLine(productInfo.Details[0].ProductName);
                        String url = productInfo.Details[0].ImageUrlLarge;
                        using (WebClient webClient = new WebClient())
                        {
                            webClient.DownloadFile(url, @"c:" + "/" + "Prince" + ".jpg");

                            /*
                             * WebRequest webReq = WebRequest.Create(productInfo.Details[0].ImageUrlMedium);
                             * WebResponse webResp = webReq.GetResponse();
                             * _image = Image.FromStream(webResp.GetResponseStream());*
                             */
                        }
                    }
                }
                catch (SoapException)
                {
                }
            }
        }