当前位置:网站首页>[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 .
边栏推荐
- Advantages of network virtualization of various manufacturers
- 数据库清空表数据并让主键从1开始
- Cloud native guide: what is cloud native infrastructure
- Do you still have certificates to participate in the open source community?
- TGA file format (waveform sound file format)
- DIY个人服务器(diy存储服务器)
- 毕业从事弱电3个月,我为什么会选择转行网络工程师
- QML combines qsqltablemodel to dynamically load data MVC "recommended collection"
- Timing analysis and constraints based on xlinx (1) -- what is timing analysis? What are temporal constraints? What is temporal convergence?
- How much memory does bitmap occupy in the development of IM instant messaging?
猜你喜欢

Network protocol: TCP part2

Distributed link logging minbox logging usage document

wallys//IPQ5018/IPQ6010/PD-60 802.3AT Input Output 10/100/1000M

JMeter - interface test

Mobile web layout method
![MySQL date [plus sign / +] condition filtering problem](/img/86/aed048e27b3e0b0baa919204bc067c.png)
MySQL date [plus sign / +] condition filtering problem

【高等数学】【3】微分中值定理与导数的应用

Kubernetes进阶部分学习笔记

Go language go language built-in container

wallys//wifi6 wifi5 router IPQ6018 IPQ4019 IPQ4029 802.11ax 802.11ac
随机推荐
[today in history] July 13: the father of database passed away; Apple buys cups code; IBM chip Alliance
谷歌Pixel 6a屏下指纹扫描仪存在重大安全漏洞
Docker 搭建 Redis Cluster集群
Proxy implements MySQL read / write separation
PMP practice once a day | don't get lost in the exam -7.25
飞行器pid控制(旋翼飞控)
[advanced mathematics] [1] function, limit, continuity
Formatdatetime explanation [easy to understand]
During the interview, I was asked how to remove the weight of MySQL, and who else wouldn't?
Do you still have certificates to participate in the open source community?
Chapter VI modified specification (SPEC) class
Remote monitoring solution of intelligent electronic boundary stake Nature Reserve
Principle analysis of bootloader
【云原生 | 从零开始学Kubernetes】八、命名空间资源配额以及标签
网络协议:TCP Part2
[today in history] July 17: Softbank acquired arm; The first email interruption; Wikimedia International Conference
Cloud native, Intel arch and cloud native secret computing three sig online sharing! See you today | issues 32-34
Redis source code -ziplist
When AI encounters life and health, Huawei cloud builds three bridges for them
【TensorRT】trtexec工具转engine