Scraping webpage generated by javascript with C#

前端 未结 3 1612
深忆病人
深忆病人 2020-11-27 03:47

I have a webBrowser, and a label in Visual Studio, and basically what I\'m trying to do is grab a section from another webpage.

I tried using WebClient.DownloadStrin

3条回答
  •  臣服心动
    2020-11-27 04:24

    Thanks to wbennet, discovered https://phantomjscloud.com. Enough free service to scrap pages through web api calls.

        public static string GetPagePhantomJs(string url)
        {
            using (var client = new System.Net.Http.HttpClient())
            {
                client.DefaultRequestHeaders.ExpectContinue = false;
                var pageRequestJson = new System.Net.Http.StringContent(@"{'url':'" + url + "','renderType':'html','outputAsJson':false }");
                var response = client.PostAsync("https://PhantomJsCloud.com/api/browser/v2/{YOUT_API_KEY}/", pageRequestJson).Result;
                return response.Content.ReadAsStringAsync().Result;
            }
        }
    

    Yeah.

提交回复
热议问题