如何使用c#从URL获取特定数据 [英] How to get particular data from a url using c#

查看:73
本文介绍了如何使用c#从URL获取特定数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友......





请帮助我从网址获取数据是https://www.alfa。 com / zh / catalog / B20430 /



在这个网址中,我想获得B20430 4-Acetamidobenzaldehyde和Bonded ware house表值以及General ware house表值和该值应保存在excel表格中。



请尽快回复

提前致谢对所有..

解决方案

并不总是一项微不足道的任务!

看一下有关该主题的一些现有文章: GoogleSite Scraping c#site:codeproject.com [ ^ ]


请参阅Andy Lanng对问题的评论。看起来他的假设是正确的。

你需要什么称为网络抓取 http://en.wikipedia.org/wiki/Web_scraping [ ^ ]。



基本上,您可能需要两件事: HttpWebRequest ,通常情况下,解析你下载的HTML。请看我过去的答案:

如何从其他网站获取数据 [ ^ ],

从网页获取特定数据 [ ^ ],

执行某种Web请求并获得结果 [ ^ ]。



我会为HTML解析添加另一条建议:使用HTML Agility Pack:

https://htmlagilitypack.codeplex.com [ ^ ],

https://www.nuget.org/packages/HtmlAgilityPack [ ^ ]。



-SA


试试这个。 ...



  string  _getUri = HttpContext.Current.Request。 Url.AbsoluteUri; 
string [] strArray = _getUri.Split(' / );
string ReqValue = strArray [ 3 ];


Hello Friends...


Please help me in getting data from a url is https://www.alfa.com/en/catalog/B20430/

In this url I want to get B20430 4-Acetamidobenzaldehyde and Bonded ware house table values and General ware house table values and that values should be saved in excel sheet.

Please give me reply as soon as possible.
Thanks in advance to all..

解决方案

Not always a trivial task!
Have a look at some of the existing articles on the subject: Google "Site Scraping c# site:codeproject.com"[^]


Please see the comment to the question by Andy Lanng. It looks like his assumptions are correct.
What you need called Web scraping: http://en.wikipedia.org/wiki/Web_scraping[^].

Basically, you may need two things: HttpWebRequest and, pretty usually, something to parse HTML you download. Please see my past answers:
How to get the data from another site[^],
get specific data from web page[^],
Performing a some kind of Web Request and getting result[^].

I would add another advice for HTML parsing: use HTML Agility Pack:
https://htmlagilitypack.codeplex.com[^],
https://www.nuget.org/packages/HtmlAgilityPack[^].

—SA


Try this one....

string _getUri = HttpContext.Current.Request.Url.AbsoluteUri;
          string[] strArray = _getUri.Split('/');
          string ReqValue = strArray[3];


这篇关于如何使用c#从URL获取特定数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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