当前位置:网站首页>[matlab] download originality documents based on oil monkey script and MATLAB
[matlab] download originality documents based on oil monkey script and MATLAB
2022-07-25 20:27:00 【Record the years of ignorance】
Preface
Recently, I found a script in the oil monkey , interesting , It can download documents that allow preview , This is a very common script , The principle is probably Auto screenshot to get pictures , Then I'll synthesize it for you PDF file . This is why only those documents that can be previewed can be downloaded .
But the interesting thing about this script is , It just doesn't give you the last step , Just give you a link containing all the photos of the document , I guess it should upload these downloaded pictures to a drawing bed , Then link its picture bed Summarize into a table in , As for why we don't do the last step of downloading pictures locally , I dare not talk about the idea of the boss , All in all , This script is very inconvenient to use .
So there is this blog , Try to use “ There's nothing but having children ” Of MATLAB To solve “ Last mile ” .
Code display
%GETPICTURE Open a link containing pictures Excel form , And download the corresponding pictures
function getpicture(filename) % Input filename Is the absolute path of the table
expression = '\w*\.csv$'; % Regular expressions , Used to remove the last level file name
end_pos = regexp(filename, expression, 'start'); % Get the cut-off position
path = extractBefore(filename, end_pos); % Keep the path before the end position —— Up path
out_path = strcat(path, 'pic_out'); % Set the path of the output picture , Keep the same directory as the original file , Name is customizable
mkdir(out_path); % You have to create this path first , because imwrite Function does not support creating nonexistent folders
[~, txt, ~] = xlsread(filename); % Read the file , Keep the string
for i = 1:length(txt) % Traverse all links
pic = webread(txt{
i}); % Download the pictures
pic_path = strcat(out_path, '\', num2str(i), '.png'); % Determine the path and name of the picture
imwrite(pic, pic_path); % Save the picture
fprintf(" Downloaded %d A picture \n", i); % For displaying progress
end
fprintf(" The download \n");
end
The comments in the code are very clear , I feel like MATLAB Basic basic can understand , The final effect is to create a pic_out Folder , It stores the downloaded pictures , As shown in the figure below .
in addition , The resulting table file is shown in the figure below .
pic_out The folder is shown below .
Function summary
This is for convenience , Briefly summarize some functions used , See the help document for specific usage .
regexp—— Used to match regular expressionsout = regexp(str, expression, outkey)return outkey Specified output . for example , If outkey by'match', beregexpReturns the substring that matches the expression instead of its start index .outkey The usual values are :
attach : Reference link See the help document for specific usage suggestions , This linked blog is also from the help document .
extractBefore—— Get the character substring before a certain position of the string
MATLAB The commonly used string processing functions in can see this The official link .
What needs to be added here is xlsread Function to get cell Type of data more reflects a Data form , Its data format (string,double,int) Or depends on the contents of the file . Let's say I set txt After output , Then you can read the string in the table , It's just When using data, the format should be correct , According to cell Type used {}.
strcat—— Connection string , Just like the one above , It is also a string handlerwebread—— Function to read web page data
At first, I want to be in MATLAB Find a function that can download online pictures , eurekaurlwritefunction , Open it Help document , It is found that this function is not recommended , It's recommendedwebwriteandwebread, Here is a download , So it's usingwebread, And then according to Help document The case given can be explored .imwrite—— Save image data locally
UsewebreadThe image data obtained is actually the binary code of the image , If you want to check it yourself , have access toimshowfunction , If you need to save to local , Then you need to useimwriteFunction , But one problem here isimwriteIt seems impossible to write a nonexistent path ( It cannot create its own path ), Will report an error without permission . So it's usingimwriteFunction before , First usemkdirCreate a path .
边栏推荐
- Kubernetes进阶部分学习笔记
- Key network protocols in tcp/ip four layer model
- 4everland storage node portal network design
- Technology cloud report: what is the difference between zero trust and SASE? The answer is not really important
- Recommended books | essentials of industrial digital transformation: methods and Practice
- Network protocol: TCP part2
- Proxy implements MySQL read / write separation
- Behind every piece of information you collect, you can't live without TA
- 每条你收藏的资讯背后,都离不开TA
- Docker builds redis cluster
猜你喜欢

【高等数学】【1】函数、极限、连续

PMP采用最新考纲,这里有【敏捷项目管理】
![[today in history] July 1: the father of time-sharing system was born; Alipay launched barcode payment; The first TV advertisement in the world](/img/41/76687ea13e1722654b235f2cfa66ce.png)
[today in history] July 1: the father of time-sharing system was born; Alipay launched barcode payment; The first TV advertisement in the world

PreScan快速入门到精通第十九讲之PreScan执行器配置、轨迹同步及非配多个轨迹

When AI encounters life and health, Huawei cloud builds three bridges for them

雷达水位计的工作原理及安装维护注意事项

Technology cloud report: more than zero trust, the wild hope of Parra's "Digital Security Cloud strategy"
![[today in history] July 19: the father of IMAP agreement was born; Project kotlin made a public appearance; New breakthroughs in CT imaging](/img/e9/5751dc435cfbbefc22d84fd9ebbaea.png)
[today in history] July 19: the father of IMAP agreement was born; Project kotlin made a public appearance; New breakthroughs in CT imaging
![[onnx] export pytorch model to onnx format: support multi parameter and dynamic input](/img/bd/e9a1d3a2c9343b75dbae5c7e18a87b.png)
[onnx] export pytorch model to onnx format: support multi parameter and dynamic input

【高等数学】【4】不定积分
随机推荐
Prescan quick start to master Lesson 19: prescan actuator configuration, track synchronization and non configuration of multiple tracks
Recommended books | essentials of industrial digital transformation: methods and Practice
Principle analysis of bootloader
[today in history] July 18: Intel was founded; The first photo was posted on the world wide web; EBay spins off PayPal
Configure and install cocos2dx development environment under Tongxin UOS
QQ是32位还是64位软件(在哪看电脑是32位还是64位)
各厂商网络虚拟化的优势
DIY个人服务器(diy存储服务器)
Stock software development
C language file reading and writing
FanoutExchange交换机代码教程
[today in history] July 4: the first e-book came out; The inventor of magnetic stripe card was born; Palm computer pioneer was born
Link list of sword finger offer question bank summary (III) (C language version)
What is cluster analysis? Categories of cluster analysis methods [easy to understand]
Distributed link logging minbox logging usage document
[Infographics Show] 248 Public Domain Name
MySQL 日期【加号/+】条件筛选问题
[advanced mathematics] [8] differential equation
网络爬虫原理解析「建议收藏」
Do you still have certificates to participate in the open source community?