
(* 指定期刊在Google Scholar上的資訊量 *)
num[journal_,year_]:=ToExpression[StringReplace[Cases[Import["http://scholar.google.com/scholar?hl=en&num=100&q=&as_publication=%22"<>StringReplace[ToString[journal]," "->"+"]<>"+%22&btnG=Search&as_sdt=0%2C5&as_ylo="<>ToString[year]<>"&as_yhi="<>ToString[year]<>"&as_vis=0","XMLObject"],{"Results ",XMLElement["b",{},{"1"}],x___}:>x,Infinity][[4,3,1]],","->""]];
(* 建立超連結 *)
link[journal_,year_,i_]:="http://scholar.google.com/scholar?start="<>ToString[i]<>"hl=en&num=100&q=&as_publication=%22"<>StringReplace[ToString[journal]," "->"+"]<>"+%22&btnG=Search&as_sdt=0%2C5&as_ylo="<>ToString[year]<>"&as_yhi="<>ToString[year]<>"&as_vis=0"
temp[journal_String,year_]:=Block[{mynum,dd1,dd2,dd3,length,aa,tempdata1,tempdata2,t1,t2,rule,title,author,cite},
mynum=100(Floor[num[journal,year]/100]);
(* 待刪除的XML引數 *)
rule=XMLElement["span",___]|XMLElement["input",___]|XMLElement["td",___]|XMLElement["br",___]|XMLElement["table",___]|XMLElement["div",{"class"->"gs_rs"},___]|XMLElement["form",___]|{"shape"->"rect","href"->___};
(* 剔除超連結非來自期刊公司資料庫的指定期刊在Google Scholar上的引用數 *)
tempdata1=Cases[Flatten[Table[(
dd1=Import[link[journal,year,i],"XMLObject"];
length=Length[dd1[[2,3,2,3]]];
Table[
(dd2=If[Length@Flatten@StringPosition[Cases[dd1[[2,3,2,3]][[z]],XMLElement["a",{"shape"->"rect","href"->hyperlink_},__]:>hyperlink,Infinity],"sciencedirect"]==0,{},If[Length[Cases[dd1[[2,3,2,3]][[z]],XMLElement["span",{"class"->"gs_ctu"},{"[CITATION]"}]|XMLElement["span",{"class"->"gs_ctc"},{"[PDF]"}]|XMLElement["span",{"class"->"gs_ctc"},{"[HTML]"}],Infinity]]==1,{},dd1[[2,3,2,3]][[z]]]];
dd3=DeleteCases[dd2,rule,Infinity]/.XMLElement->List;
title=Cases[dd3,{_,{"class"->"gs_rt"},title_}:>title,Infinity];
author=Cases[dd3,{_,{"class"->"gs_a"},{author_,___}}:>author,Infinity];
cite=Cases[dd3,{_,{"class"->"gs_fl"},cite_}:>cite,Infinity];
Flatten[{title,author,cite},1]
),{z,length}]),{i,0,mynum,100}],1],{_,___}];
tempdata2=Table[{If[Length[tempdata1[[z]][[1]]]==1,tempdata1[[z]][[1,1,-1]],tempdata1[[z]][[1,1,-1]]<>" "<>tempdata1[[z]][[1,2,-1]]],tempdata1[[z]][[2]],If[Length[tempdata1[[z]]]<3,{},tempdata1[[z]][[3,1,2]]]},{z,Length@tempdata1}] ]
(* 範例:將European Journal of Operational Research在2008年的文章資訊匯出到test.xls *)
Export["test.xls", temp["European Journal of Operational Research", 2008]]
(*將European Journal of Operational Research在2000~2010年的所有文章資訊輸出*)
ejordata=Block[{data,cite}, data=temp["European Journal of Operational Research",#]; cite=Total@Table[ If[Length[Flatten[StringPosition[data[[z,-1]],"Cited"]]]>0,
Read[StringToStream@data[[z,-1,1]],{Word,Word,
Number}][[-1]],0],{z,Length@data}];
{Length@data,cite,cite/Length[data]}
]&/@Range[2000,2010]
(* EJOR各年度在 Google Scholar 的引用量 *)
BarChart[ejordata[[All, 2]], ChartLabels -> Range[2000, 2010, 1], ImageSize -> 500]
Tags:
Mathematica 教學
讀者回應 ( 0 意見 )
訂閱發佈留言 (Atom)
發佈留言
Please leave your name and tell me what you thought about this site. Comments, suggestions and views are welcomed.
如果這篇文章對你有幫助,那請留個訊息給我~