当前位置:网站首页>[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 .
边栏推荐
- Apache MINA框架「建议收藏」
- 【TensorRT】动态batch进行推理
- [advanced mathematics] [3] Application of differential mean value theorem and derivative
- RF, gbdt, xgboost feature selection methods "recommended collection"
- 网络协议:TCP Part2
- 【云原生 | 从零开始学Kubernetes】八、命名空间资源配额以及标签
- Summarize the level of intelligent manufacturing discussion [macro understanding]
- CarSim simulation quick start (XV) - ADAS sensor objects of CarSim sensor simulation (1)
- Configure and install cocos2dx development environment under Tongxin UOS
- [advanced mathematics] [8] differential equation
猜你喜欢
![[today in history] July 4: the first e-book came out; The inventor of magnetic stripe card was born; Palm computer pioneer was born](/img/0b/73f0d98a6db813e54074abe199ed98.png)
[today in history] July 4: the first e-book came out; The inventor of magnetic stripe card was born; Palm computer pioneer was born

PMP practice once a day | don't get lost in the exam -7.25

Do you still have certificates to participate in the open source community?
![[today in history] July 17: Softbank acquired arm; The first email interruption; Wikimedia International Conference](/img/0f/8ce2d5487b16d38a152cfd3ab454bb.png)
[today in history] July 17: Softbank acquired arm; The first email interruption; Wikimedia International Conference

During the interview, I was asked how to remove the weight of MySQL, and who else wouldn't?

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

推荐系统专题 | MiNet:跨域CTR预测

网络协议:TCP Part2

笔记——记录一个CannotFindDataSourceException: dynamic-datasource can not find primary datasource问题解决

Introduction and construction of consul Registration Center
随机推荐
C language file reading and writing
【高等数学】【5】定积分及应用
Do you still have certificates to participate in the open source community?
wallys//IPQ5018/IPQ6010/PD-60 802.3AT Input Output 10/100/1000M
Myormframeworkjdbc review and problem analysis of user-defined persistence layer framework, and thought analysis of user-defined persistence layer framework
qml 结合 QSqlTableModel 动态加载数据 MVC「建议收藏」
Working principle of radar water level gauge and precautions for installation and maintenance
雷达水位计的工作原理及安装维护注意事项
[cloud native | learn kubernetes from scratch] VIII. Namespace resource quotas and labels
9. < tag dynamic programming and subsequence, subarray> lt.718. Longest repeated subarray + lt.1143. Longest common subsequence
股票软件开发
各厂商网络虚拟化的优势
Clickhouse notes 02 -- installation test clickvisual
PreScan快速入门到精通第十九讲之PreScan执行器配置、轨迹同步及非配多个轨迹
Stock software development
【高等数学】【4】不定积分
Mobile web layout method
Vivo official website app full model UI adaptation scheme
Web crawler principle analysis "suggestions collection"
4. Server startup of source code analysis of Nacos configuration center