Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.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
带有(可能)屏蔽IP的网页抓取C#_C#_Visual Studio 2012 - Fatal编程技术网

带有(可能)屏蔽IP的网页抓取C#

带有(可能)屏蔽IP的网页抓取C#,c#,visual-studio-2012,C#,Visual Studio 2012,我走了,试着用手在C#中刮网。我在Youtube上找到了Blake B的一段视频,显示了将易趣物品放入列表的过程,非常酷。我也在尝试做一些类似的事情,但我在HTML部分挣扎,在哪里替换,这是我到目前为止所做的 using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Net.Http; namespace CarRegRet

我走了,试着用手在C#中刮网。我在Youtube上找到了Blake B的一段视频,显示了将易趣物品放入列表的过程,非常酷。我也在尝试做一些类似的事情,但我在HTML部分挣扎,在哪里替换,这是我到目前为止所做的

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http;

namespace CarRegRetrieve
{
    class Program
    {
        static void Main(string[] args)
        {
            GetHTMLAsync();
            Console.ReadLine();
        }

        private static async void GetHTMLAsync()
        {
            var url = "https://www.rapidcarcheck.co.uk/results?RegPlate=LN52dmv";
            var httpClient = new HttpClient();
            var html = await httpClient.GetStringAsync(url);

            var htmlDoc = new HtmlAgilityPack.HtmlDocument();
            htmlDoc.LoadHtml(html);

            var ProductsHTML = htmlDoc.DocumentNode.Descendants("body")
                .Where(node => node.GetAttributeValue("wpb_text_column wpb_content_element", "")
                .Equals("wpb_wrapper")).ToList();

            var productLists = ProductsHTML[0].Descendants();

            Console.WriteLine(productLists);

        }

    }
这是通过输入注册来获取汽车信息的开始,正如您所看到的,我使用的网站是RapidCarCheck,我已经输入了我的注册,希望获得发动机尺寸、最高速度等。我已经查看了页面上的inspect元素,但不知道我在寻找什么

请注意,如果这是一个简单的修复方法,请务必注意,但该网站是Cloudfare反请求阻止类型的东西,并且没有代理来隐藏或更改我的IP,这使得我很难编写项目代码,因为我一直需要手动更改我的IP


谢谢

可能不是很有帮助,但我建议查看易趣的API。网页抓取——虽然可能——通常不是一个好主意。除非有要求说你需要刮网页,否则我会避免尝试。Hello@Dortimer,谢谢你的快速回复,我目前正在学习A级,我的课程是制作计算汽车财务的软件,我希望添加从上述网站获取信息的功能,为项目添加一点“改进”: