始终返回首页的内容 [英] Content from first page returned always

查看:56
本文介绍了始终返回首页的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从以下路径进行webrequest.但是每次我请求时,它都返回第一个页面的内容,而不是第二个页面.

I want to make webrequest from the following path. But everytime I request it returns the contents of the firtst page not the second one.

public static string FetchWebpageSourceContent()
        {
          string _path="http://www.amazon.com/s/ref=sr_nr_i_0?rh=k%3Ajewelry+deals%2Ci%3Ajewelry&keywords=jewelry+deals&ie=UTF8&qid=1341384452#/ref=sr_pg_2?rh=k%3Ajewelry+deals%2Cn%3A3367581&page=2" 
 
          try
            {
                var req = HttpWebRequest.Create(_path);
                var response = req.GetResponse();

                return new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd();
            }
            catch (Exception ex)
            {
                return String.Empty;
            }
        }

推荐答案

我将使用另一个URL对其进行检查,并使用包含另一个页面查询字符串的工作文件进行检查.而且工作正常.您的代码中没有错误或任何错误,以为url包含可以自动将其重定向到首页的内容.

选择两个页面的第二个url工作文件.

I will check it with another URL, and it''s working file with query string for another page. and it''s working fine. there is no bug or any error in your code, ithink that url is have something which will redirect it to first page autometically.

the second url working file with 2 page selection.

public static string FetchWebpageSourceContent()
        {
            string _path = "http://www.amazon.com/s/ref=sr_nr_i_0?rh=k%3Ajewelry+deals%2Ci%3Ajewelry&keywords=jewelry+deals&ie=UTF8&qid=1341384452#/ref=sr_pg_2?rh=k%3Ajewelry+deals%2Cn%3A3367581&page=2";
            string _path2 = "http://www.codeproject.com/script/Answers/List.aspx?tab=unanswered&pgnum=2";
          try
            {
                var req = HttpWebRequest.Create(_path2);
                var response = req.GetResponse();

                return new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd();
            }
            catch (Exception ex)
            {
                return String.Empty;
            }
        }


这篇关于始终返回首页的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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