-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetchildren.m
79 lines (74 loc) · 1.92 KB
/
getchildren.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
function [cid, cn, pid, pn] = getchildren(c)
%function [cid, cn, pid, pn] = getchildren(c)
%
%getparents downloads the parent ids and parents names of scholar c
%output is organized as two pairs of cell arrays, for names and ids
%
%22 March, Richard S.J. Tol
site = strcat('https://academictree.org/econ/peopleinfo.php?pid=',c);
s = webread(site);
if length(s) > 0
%get name
sep0 = findstr(s,'<TITLE>');
sep1 = findstr(s,'</TITLE>');
s1 = s(sep0+7:sep1-1);
sep0 = findstr(s1,'-');
pname = s1(sep0+2:length(s1));
pname = strrep(pname,' ',' ');
%get children
sep0 = findstr(s,'Construct Child Connection Container');
sep1 = findstr(s,'Construct Collaborator Connection Container');
s1 = s(sep0:sep1);
sep0 = findstr(s1,'pid=');
np = length(sep0);
pidh = cell(1,np);
cidh = cell(1,np);
pnh = cell(1,np);
cnh = cell(1,np);
for i = 1:np
j=0;
while s1(sep0(i)+4+j)~='"'
s2(j+1) = s1(sep0(i)+4+j);
j=j+1;
end
j=j+2;
l = 1;
while s1(sep0(i)+4+j)~='<'
s3(l) = s1(sep0(i)+4+j);
j=j+1;
l=l+1;
end
cidh{i} = s2;
pidh{i} = c;
cnh{i} = strrep(strrep(s3,' ',' '),' ',' ');
pnh{i} = strrep(pname,' ',' ');
clear s2 s3
end
end
%remove duplicate children
if size(pidh,2) > 2
cid{1} = cidh{1};
cn{1} = cnh{1};
pid{1} = pidh{1};
pn{1} = pnh{1};
for i=2:size(cidh,2)
j=size(cid,2);
copy = true;
for l=1:j
copy = copy & ~strcmp(cidh{i},cid{l});
end
if copy
j=j+1;
cid{j} = cidh{i};
cn{j} = cnh{i};
pid{j} = pidh{i};
pn{j} = pnh{i};
end
end
else
cid = cidh;
cn = cnh;
pid = pidh;
pn = pnh;
end
end