Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 从特定节点接收信息_.net_Html Agility Pack - Fatal编程技术网

.net 从特定节点接收信息

.net 从特定节点接收信息,.net,html-agility-pack,.net,Html Agility Pack,问题是我一直在解析同一个页面。我该如何解决这个问题,我做错了什么?如何从特定站点获取信息 //General url ("https://www.zieglers.com/church-goods/church-furnishings/altar-sets/?sort=featured&page=1") public static void GetProductsLinks(string url) { var html = HtmlRetri

问题是我一直在解析同一个页面。我该如何解决这个问题,我做错了什么?如何从特定站点获取信息

//General url ("https://www.zieglers.com/church-goods/church-furnishings/altar-sets/?sort=featured&page=1")
public static void GetProductsLinks(string url) 
    {
        var html = HtmlRetriever(url);

        if (string.IsNullOrEmpty(html))
            return;
        var doc = new HtmlDocument();
        doc.LoadHtml(html);

        //Get All products from this page
        var tag = doc.DocumentNode.SelectNodes("//figure[@class='card-figure']/a");

        if (tag == null)
            return;
        // Check if there is a button next
        var nextButtonIsExist = doc.DocumentNode.SelectSingleNode(
            "//link[@rel = 'next']");


        //if exist form a new link ("https://www.zieglers.com/church-goods/church-furnishings/altar-sets/?sort=featured&page=2")
        if (nextButtonIsExist != null)
        {
            url  = nextButtonIsExist.Attributes["href"].Value;
        }

        // I fill the List <string> with links to all items from this page
        foreach (var item in tag)
        {
            var tok = item.InnerText;
            linksProductsList.Add(item.Attributes["href"].Value);
        }

        // If there is a button next, then we pass our newly generated url
        if (nextButtonIsExist != null)
        {
            GetProductsLinks(url);
        }
    }
//通用url(“https://www.zieglers.com/church-goods/church-furnishings/altar-sets/?sort=featured&page=1")
公共静态无效GetProductsLinks(字符串url)
{
var html=HtmlRetriever(url);
if(string.IsNullOrEmpty(html))
返回;
var doc=新的HtmlDocument();
doc.LoadHtml(html);
//从该页面获取所有产品
var tag=doc.DocumentNode.SelectNodes(//figure[@class='card-figure']/a);
if(标记==null)
返回;
//检查下一步是否有按钮
var nextButtonIsExist=doc.DocumentNode.SelectSingleNode(
“//链接[@rel='next']”;
//如果存在,请创建一个新链接(“https://www.zieglers.com/church-goods/church-furnishings/altar-sets/?sort=featured&page=2")
if(nextButtonIsExist!=null)
{
url=nextButtonIsExist.Attributes[“href”].Value;
}
//我用指向此页面中所有项目的链接填充列表
foreach(标签中的变量项)
{
var tok=item.InnerText;
linksProductsList.Add(item.Attributes[“href”].Value);
}
//如果下一步有一个按钮,那么我们将传递新生成的url
if(nextButtonIsExist!=null)
{
获取产品链接(url);
}
}
问题是网站有分页功能,每个链接有2-6页,你能告诉我如何解析吗