TA的每日心情 | 郁闷 2018-12-17 20:03 |
---|
签到天数: 2 天 [LV.1]初来乍到
|
发表于 2014-9-7 17:27:40
|
显示全部楼层
本帖最后由 zjzengdongyang 于 2014-9-7 17:38 编辑 7 U; p7 i2 E0 }3 V% d" t
. P$ q0 e) M6 iC语言 main.c 单词列表下载,需要grep,curl,tail,head命令,支持断点续传- /*! a0 q& r; Q; j5 j# l0 M i
- 0.txt 下次要下载的东西
) Y: y F5 _) i - 1.txt 下载过来的临时性的源文件
- P7 g( d% S5 e4 X, u$ J - 2.txt 提取出来的单词链接名' d1 e% g0 S C2 `
0 [3 f$ \) c" X) W) f- */) v: i" c9 G" q! @6 N& U$ ?& \
- int downlist ();+ T. z* N; r. R) p2 ]& l
- int xhpd ();//循环判断% Q3 j" V% j i) J9 F* j5 W4 Q0 ~
- char jwword[500] = "zzz";//结尾单词3 h' [: ?* _/ M" A, a% x
- : M) J- e* P) w% B
- int main ()* j5 F5 X! ~: k/ t% l& ?
- {
$ Z v* t& |- B p$ [ - int a;1 a; B& Y- q5 t& X _
- a=xhpd ();
* D' h+ t$ F2 S4 m. O - 9 k/ R* S7 s4 f }8 x6 J* r7 y6 j8 Z
- while (a==1)
: [, o: u5 F/ r) \6 B: n* P - {& }. E: G% `6 I) v, R
- downlist();* a. o2 p& i; W3 M0 E9 O* G! f P
- a=xhpd ();- {4 n( r. \* d. q O$ ^3 x: E
- }
# m4 u2 ]2 T4 W - printf("单词列表已下载完成");
* U8 V) d' s" K - return 0;& x7 s1 j8 F- }% Y# p
- }. R1 _. Q5 \) b' m
5 d/ n L! U# I. k- int downlist ()
6 f/ b4 Y" W/ m( r8 s2 Q - {# n# P+ i" y! z2 n+ ^5 _+ `
- char downml[500]; //下载命令# Z* K. g \. u" _( S7 C
- char downlistword[500]; //0.txt中储存的单词
% i: c* |- T% z4 S6 r3 S( _ - FILE * fp1;
; e% Q1 C6 ]0 K R - fp1 = fopen("0.txt", "rt");
1 F0 T P, B- l - strcpy(downml, ".\\curl -o 1.txt http://global.longmandictionaries.com/dict_search/get_entry_chunk_for_alpha_key/ldoce6/");
* K& p; b7 @2 O$ W - fgets(downlistword, 501, fp1);
- m5 @$ X2 @: f, m6 Z - downlistword[strlen(downlistword)-1]='\0';
2 b5 k6 L' W7 j. q1 ?, F2 f8 i& ~ - strcat(downml,downlistword);
( k* |9 I* r. J - fclose(fp1); @8 ]0 U) h1 _6 N, O
- strcat(downml,"/1/");
9 x2 _" h. R" Y0 L - printf("%s\n",downml);' f" u$ u) O H4 I- N# x5 _; y% S3 m
- system(downml);
8 a5 n" o o9 ?! |$ s, a) k - system(".\\grep -oP "(?<=data-alphakey=\\").*?(?=\\")" 1.txt >>2.txt");. D$ l6 M3 d3 ]
- system(".\\tail -n 1 2.txt >0.txt");# o+ P5 `* H$ m- ?5 q, Z
- 6 o- z3 a- R! q& u0 k9 S1 k2 Q& O
- return 0;9 Q# R8 j Z5 L2 W' `
- }4 d! L: L- V$ a) u# j( O
- % G; D( m& B2 \. x- r! Q
- int xhpd ()
5 p# N, X2 }# @7 n8 b# \ - {
& w" S2 h/ k2 f9 s0 Y - char downlistword[500];0 Z c' {, t& i# G; n- g
- FILE * fp1;7 y. S! G4 [% }/ N. {( V2 N; C
- fp1 = fopen("0.txt", "rt");
* A, N4 S& U9 K4 s" m2 r9 z8 k - fgets(downlistword, 501, fp1);2 H0 @" D& y' t7 D: K
- downlistword[strlen(downlistword)-1]='\0';" ~% u- E: U7 p# [# |% g
- fclose(fp1);9 `' H8 r% b# J2 ]2 P. Q$ e! E& ]/ l
- if (strcmp(downlistword,jwword)==0)3 b/ z, [7 c, f4 L2 D0 @3 Y
- {& {, Y2 H3 L' \6 |% i* a* l) c! X
- return 0;
: u5 y1 m7 B- x- f. m - }9 Y1 s& T; u e8 P
- else return 1;
/ x- J0 o& b0 }/ \# E - return 3;
4 d0 R0 d' }/ c1 p1 [* i - }
/ }: K4 r6 u$ r) f
复制代码 englist.7z(1.73MB) |
|