forked from csdms-contrib/topotoolbox
-
Notifications
You must be signed in to change notification settings - Fork 90
/
tthelp.m
53 lines (44 loc) · 1.09 KB
/
tthelp.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
function tthelp(str,page)
%TTHELP Search on the TopoToolbox blog
%
% Syntax
%
% tthelp keyword
% tthelp('keyword')
%
% Description
%
% TTHELP lets you search the TopoToolbox blog and returns links to the
% blog to the command line.
%
% Example
%
% tthelp ksn
%
% Note that this function may not work properly if wordpress does changes
% to its html-code.
%
% Author: Wolfgang Schwanghart (w.schwanghart[at]geo.uni-potsdam.de)
% Date: 22. July, 2022
if nargin == 1
page = 1;
end
% First page URL
if page == 1
url = 'https://topotoolbox.wordpress.com/?s=';
else
pagestr = num2str(page);
url = ['https://topotoolbox.wordpress.com/page/' pagestr '/?s='];
end
t = webread([url str]);
[tokens,matches] = regexp(t,'<h3>(.*?)</h3>','tokens','match');
for r = 1:numel(tokens)
% replace with blank
tokens{r} = replace(tokens{r},' ',' ');
disp(tokens{r}{1})
end
% now check whether there's another page with results
findnextstr = '<li><a class="next page-numbers" (.*?)>Next →</a></li>';
if ~isempty(regexp(t,findnextstr,'once'))
tthelp(str,page+1)
end