使用任务并行库一次爬行多个URL
我想使用多个 URL 抓取数据并将数据存储在 SQLite 中,我应该使用并行吗?为每个循环调用或并行抓取 URL 并获取数据。我对如何执行项目的这一部分感到困惑。我也在努力如何开始我的项目的这一部分,该部分实际上是在网站中抓取不同语言的文章
I want to Crawl data using multiple URL's and store the data in SQLite, Should I use Parallel. Invoke or parallel for each loop too crawl the URL and fetch the data. I am confused on how to execute this part of my project. I am also struggling on how to start this part of my project which actually crawls articles from different languages in a website
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
tpl(任务并行库)与异步/等待的问题是您的任务CPU绑定(并行计算多个内容)或I/O绑定(与多个文件或网络请求进行交互)。
由于您喜欢抓取多个URL的事实,您的工作是I/O绑定,这使其成为异步/等待的良好候选人。因此,您可以并行请求列表的所有(或子集)。一些示例代码看起来像这样:
TPL (task parallel library) vs. async/await is the question about, is your task CPU bound (calculate multiple things in parallel) or I/O bound (interact with multiple files or network requests).
Due to the fact, that you like to crawl multiple URLs, your jobs is I/O bound, which makes it a good candidate for async/await. So you could request all (or a subset) of your list in parallel. Some example code would look something like this: