如何进行网页抓取 [英] How to do web scraping
本文介绍了如何进行网页抓取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用网页抓取将所有文本存储在excel和输出文件中。
需要帮助,因为我是C#
I want all text to be stored in excel and output file using web scraping.
Need help as i'm new to C#
推荐答案
您可以使用类System.Net.HttpWebRequest
通过HTTP检索资源:
HttpWebRequest Class(System.Net) [ ^ ]。
他们需要从检索到的HTML中提取URL。为此,您需要解析此HTML。请查看此比较表: HTML解析器的比较 - 维基百科,免费的百科全书 [ ^ ]。
我会推荐一个解析器是HTML Agility Pack: Html Agility Pack - 主页 [ ^ ]。
参见:网页抓取 - 维基百科,免费的百科全书 [ ^ ]。
-SA
You can retrieve resources via HTTP by using the classSystem.Net.HttpWebRequest
:
HttpWebRequest Class (System.Net)[^].
Them you would need to extract the URLs from HTML retrieved. For this purpose, you would need to parse this HTML. Please review this comparison sheet: Comparison of HTML parsers — Wikipedia, the free encyclopedia[^].
One parser I would recommend is HTML Agility Pack: Html Agility Pack — Home[^].
See also: Web scraping — Wikipedia, the free encyclopedia[^].
—SA
这篇关于如何进行网页抓取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文