当前位置:网站首页>[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 .
边栏推荐
- RF、GBDT、XGboost特征选择方法「建议收藏」
- “链”接无限可能:数字资产链,精彩马上来!
- [advanced mathematics] [5] definite integral and its application
- Formatdatetime explanation [easy to understand]
- Learn FPGA from the bottom structure (16) -- customization and testing of pll/mmcm IP
- [today in history] July 8: PostgreSQL release; SUSE acquires the largest service provider of k8s; Activision Blizzard merger
- Difference Between Accuracy and Precision
- Proxy implements MySQL read / write separation
- 103. (cesium chapter) cesium honeycomb diagram (square)
- test
猜你喜欢

4everland storage node portal network design

Recommended books | essentials of industrial digital transformation: methods and Practice

Cloud native guide: what is cloud native infrastructure

Working principle of radar water level gauge and precautions for installation and maintenance

Distributed link logging minbox logging usage document

Volcanic engine Xiang Liang: machine learning and intelligent recommendation platform multi cloud deployment solution officially released

Cloud native, Intel arch and cloud native secret computing three sig online sharing! See you today | issues 32-34
![[advanced mathematics] [8] differential equation](/img/83/b6b07540e3cf6d6433e57447d42ee9.png)
[advanced mathematics] [8] differential equation

从底层结构开始学习FPGA(16)----PLL/MMCM IP的定制与测试

Kubernetes进阶部分学习笔记
随机推荐
Mobile web layout method
Do you still have certificates to participate in the open source community?
FanoutExchange交换机代码教程
Docker 搭建 Redis Cluster集群
Configure and install cocos2dx development environment under Tongxin UOS
[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 quick start to master Lesson 19: prescan actuator configuration, track synchronization and non configuration of multiple tracks
【云原生 | 从零开始学Kubernetes】八、命名空间资源配额以及标签
【高等数学】【3】微分中值定理与导数的应用
Docker builds redis cluster
Timing analysis and constraints based on xlinx (1) -- what is timing analysis? What are temporal constraints? What is temporal convergence?
4. Server startup of source code analysis of Nacos configuration center
securecrt乱码解决方法[通俗易懂]
第六章 修改规范(SPEC)类
RF, gbdt, xgboost feature selection methods "recommended collection"
[today in history] July 17: Softbank acquired arm; The first email interruption; Wikimedia International Conference
Fanoutexchange switch code tutorial
[today in history] July 18: Intel was founded; The first photo was posted on the world wide web; EBay spins off PayPal
CarSim simulation quick start (16) - ADAS sensor objects of CarSim sensor simulation (2)
PMP practice once a day | don't get lost in the exam -7.25