C# extract img url from web content then download the img
static void Main(string[] args)
{
WebClientDemo(); Console.ReadLine();
} static void WebClientDemo()
{
webContent = File.ReadAllText("img2.txt");
var urlsList = webContent.Split(new string[] { "\"", "" }, StringSplitOptions.None).ToList().Where(x => x.StartsWith("http")).Where(x => x.EndsWith("jpg") || x.EndsWith(".png") || x.EndsWith(".jpeg")); foreach (var ul in urlsList)
{
WebClientDownload(ul);
}
} static void WebClientDownload(string url)
{
try
{
using (WebClient wc = new WebClient())
{ string[] urls = url.Split(new string[] { "/" }, StringSplitOptions.None);
string fileName = "Imgs2\\"+ urls[urls.Length - ];
wc.DownloadFile(url, fileName);
++num;
Console.WriteLine(url);
}
}
catch
{ }
}
C# extract img url from web content then download the img的更多相关文章
- springboot Serving Web Content with Spring MVC
Serving Web Content with Spring MVC This guide walks you through the process of creating a "hel ...
- URL相关Web APIs
参考文档:MDN> Web API接口 > URLUtils MDN > Web API接口 > URL MDN > Web API接口 > Location MD ...
- java.lang.ClassNotFoundException: org.springframework.web.content.ContextLoaderListener
1.错误描写叙述 严重: Error configuring application listener of class org.springframework.web.content.Context ...
- HttpApplication IHttpAsyncHandler, IHttpHandler, IComponent, IDisposable ps url System.Web.dll
// 摘要: // 定义 ASP.NET 应用程序中的所有应用程序对象共有的方法.属性和事件.此类是用户在 Global.asax 文件中所定义的应用程序的基类. [Toolb ...
- 关于URL、Web的一些概念
关于URL ★ 书写路径时,网络文件用斜杠“/”划分不同层级,本地文件管理系统用反斜杠“\”,分隔不同层级: 如下图示 ★ 绝对/相对 ...
- Java通过URL 从web服务端获取数据
1.Java 通过HttpURLConnection Post方式提交json,并从服务端返回json数据 package Demo.Test; import java.io.ByteArrayOut ...
- python网络爬虫(14)使用Scrapy搭建爬虫框架
目的意义 爬虫框架也许能简化工作量,提高效率等.scrapy是一款方便好用,拓展方便的框架. 本文将使用scrapy框架,示例爬取自己博客中的文章内容. 说明 学习和模仿来源:https://book ...
- odoo开发笔记 -- 还原数据库后,异常:ir_attachment: IOError: [Errno 2] No such file or directory: u'/var/...'
场景描述: 恢复Odoo数据后,抛出错误导致无法进入页面 -- ::, INFO aeo odoo.addons.base.ir.ir_attachment: _read_file reading / ...
- odoo13之文件预览widget/模块
本文示例代码可查看github仓库:odoo13_file_preview 文件预览效果图展示 效果描述: 1.当点击图片或者文件时展开图片. 2.当点击关闭按钮时关闭图片预览. 3.当点击下载按钮时 ...
随机推荐
- kakfa+zookeeper集群搭建
1:下载对应安装包 zookeeper-3.4.14.tar.gz:链接:https://pan.baidu.com/s/19_eYsv5r9bg0AKv3TzjpZQ 提取码:ik8a kaf ...
- 使用 pyenv 管理不同的 Python 版本
1. pyenv 的安装 $ yum install git -y $ yum install gcc make patch gdbm-devel openssl-devel sqlite-devel ...
- VNC 远程桌面 连接(安装桌面程序)
1.修改linux启动方式 # vi /etc/inittab 将3改为5 id:5:initdefault: 2.关闭防火墙(或者单独打开接口) #s ...
- [MacOS-Memcached]安装
查看memcached信息 $ brew info memcached memcached: stable 1.5.22 (bottled), HEAD High performance, distr ...
- Linux运维--12.手动部署Rabbit集群
1.安装rabbit组件 10.100.2.51 controller1 10.100.2.52 controller2 10.100.2.53 controller3 #每个节点 yum insta ...
- [WPF 学习] 3.用户控件库使用资源字典的困惑
项目需要(或者前后端分离的需要),前端我使用了用户控件库,由后端用代码加载和控制. 然而用户控件库没法指定资源字典,于是在用户控件的xaml文件里面手工添加了资源字典 <UserControl. ...
- Python3标准库:pprint美观打印数据结构
1. pprint美观打印数据结构 pprint模块包含一个“美观打印机”,用于生成数据结构的一个美观的视图.格式化工具会生成数据结构的一些表示,不仅能够由解释器正确地解析,还便于人阅读.输出会尽可能 ...
- SAP MM 采购订单与相关合同的价格差异问题分析
SAP MM 采购订单与相关合同的价格差异问题分析 笔者所在的项目里,一般生产性物料PO的价格是来自于合同价格的,而合同的价格来自于采购信息记录的价格,业务部门不允许PO里随便改价格的. 但是业务部门 ...
- mybatis 测试输出SQL语句到控制台配置
1: mybatis-config.xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE ...
- PHP将图片base64编码传输
PHP函数源码 function imgToBase64($img_file) { $img_base64 = ''; if (file_exists($img_file)) { $app_img_f ...