-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathTutorial_180716_Crawling_Shuffle.html
More file actions
998 lines (486 loc) · 41.3 KB
/
Tutorial_180716_Crawling_Shuffle.html
File metadata and controls
998 lines (486 loc) · 41.3 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
<!DOCTYPE HTML>
<html lang="" >
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>저작권과 직업윤리를 인지하고 크롤링 셔플 실습 · GitBook</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content="">
<meta name="generator" content="GitBook 3.2.3">
<link rel="stylesheet" href="gitbook/style.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
<link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
<meta name="HandheldFriendly" content="true"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
<link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">
<link rel="next" href="Tutorial_180716_Markup_Html5lib.html" />
<link rel="prev" href="Tutorial_180713_ExperimentDesignLecture.html" />
</head>
<body>
<div class="book">
<div class="book-summary">
<div id="book-search-input" role="search">
<input type="text" placeholder="Type to search" />
</div>
<nav role="navigation">
<ul class="summary">
<li class="chapter " data-level="1.1" data-path="./">
<a href="./">
Introduction
</a>
</li>
<li class="chapter " data-level="1.2" data-path="Tutorial_180628_Git_and_Github.html">
<a href="Tutorial_180628_Git_and_Github.html">
Git과 Github, 기본 개념과 설명
</a>
</li>
<li class="chapter " data-level="1.3" data-path="Tutorial_180629_Git_with_constitution.html">
<a href="Tutorial_180629_Git_with_constitution.html">
헌법개정안으로 깃베쉬, 소스트리, 브랜치 이해하기
</a>
</li>
<li class="chapter " data-level="1.4" data-path="Tutorial_180629_Github_practice_Statistics1.html">
<a href="Tutorial_180629_Github_practice_Statistics1.html">
확률통계 기초와 깃허브 실습
</a>
</li>
<li class="chapter " data-level="1.5" data-path="Tutorial_180629_Statistics.html">
<a href="Tutorial_180629_Statistics.html">
통계 기본 개념과 설명
</a>
</li>
<li class="chapter " data-level="1.6" data-path="Tutorial_180702_Programming_Intro.html">
<a href="Tutorial_180702_Programming_Intro.html">
스크래치 실습을 통한 프로그래밍 맛보기
</a>
</li>
<li class="chapter " data-level="1.7" data-path="Tutorial_180702_tidydata.html">
<a href="Tutorial_180702_tidydata.html">
데이터다루기(tidydata)와 프로그래밍기초
</a>
</li>
<li class="chapter " data-level="1.8" data-path="Tutorial_180703_Python_introduction.html">
<a href="Tutorial_180703_Python_introduction.html">
파이썬 기초
</a>
</li>
<li class="chapter " data-level="1.9" data-path="Tutorial_180705_PythonReview_Lamda.html">
<a href="Tutorial_180705_PythonReview_Lamda.html">
범죄데이터로 파이썬 실습 (Lamda)
</a>
</li>
<li class="chapter " data-level="1.10" data-path="Tutorial_180705_Resume_01.html">
<a href="Tutorial_180705_Resume_01.html">
특강-자기소개서 워크숍(1)
</a>
</li>
<li class="chapter " data-level="1.11" data-path="Tutorial_180706_Civic_hacking_seminar.html">
<a href="Tutorial_180706_Civic_hacking_seminar.html">
특강-시빅해킹
</a>
</li>
<li class="chapter " data-level="1.12" data-path="Tutorial_180709_StaticBlogging_JekyllandRuby.html">
<a href="Tutorial_180709_StaticBlogging_JekyllandRuby.html">
지킬과 루비로 정적 블로그 만들기
</a>
</li>
<li class="chapter " data-level="1.13" data-path="Tutorial_180710_Lecture_Cooperation.html">
<a href="Tutorial_180710_Lecture_Cooperation.html">
특강-협업
</a>
</li>
<li class="chapter " data-level="1.14" data-path="Tutorial_180710_Lecture_Speciality.html">
<a href="Tutorial_180710_Lecture_Speciality.html">
특강-전문성
</a>
</li>
<li class="chapter " data-level="1.15" data-path="Tutorial_180712_DataVisualization101.html">
<a href="Tutorial_180712_DataVisualization101.html">
데이터 시각화 이해
</a>
</li>
<li class="chapter " data-level="1.16" data-path="Tutorial_180712_AttraciveResume2.html">
<a href="Tutorial_180712_AttraciveResume2.html">
특강-자기소개서 워크숍(2)
</a>
</li>
<li class="chapter " data-level="1.17" data-path="Tutorial_180713_Pandas101.html">
<a href="Tutorial_180713_Pandas101.html">
자료의 요약 과제를 통한 판다스 실습
</a>
</li>
<li class="chapter " data-level="1.18" data-path="Tutorial_180713_ExperimentDesignLecture.html">
<a href="Tutorial_180713_ExperimentDesignLecture.html">
특강-실험계획에 관해 알아보기
</a>
</li>
<li class="chapter active" data-level="1.19" data-path="Tutorial_180716_Crawling_Shuffle.html">
<a href="Tutorial_180716_Crawling_Shuffle.html">
저작권과 직업윤리를 인지하고 크롤링 셔플 실습
</a>
</li>
<li class="chapter " data-level="1.20" data-path="Tutorial_180716_Markup_Html5lib.html">
<a href="Tutorial_180716_Markup_Html5lib.html">
Markup Html5lib, 파이썬으로 크롤링하기
</a>
</li>
<li class="chapter " data-level="1.21" data-path="Tutorial_180717_10minPandas.html">
<a href="Tutorial_180717_10minPandas.html">
Pandas 10분 완성
</a>
</li>
<li class="chapter " data-level="1.22" data-path="Tutorial_180717_PandasPetition.html">
<a href="Tutorial_180717_PandasPetition.html">
국민청원 첫시작 판다스로 국민청원하기
</a>
</li>
<li class="chapter " data-level="1.23" data-path="Tutorial_180719_BeautifulSoup.html">
<a href="Tutorial_180719_BeautifulSoup.html">
Beautiful Soup을 사용하여 크롤링
</a>
</li>
<li class="chapter " data-level="1.24" data-path="Tutorial_180719_plotnine.md">
<span>
국민청원 데이터 시각화와 자연어 처리-plontnine 실습하기
</a>
</li>
<li class="chapter " data-level="1.25" data-path="Tutorial_180720_coupang.html">
<a href="Tutorial_180720_coupang.html">
특강 - 비전공자가 데이터 분석가로 취업하기
</a>
</li>
<li class="chapter " data-level="1.26" data-path="Tutorial_180720_ProbabilityDistribution.html">
<a href="Tutorial_180720_ProbabilityDistribution.html">
통계학-자료의 요약, 확률분포(ProbabilityDistribution)
</a>
</li>
<li class="chapter " data-level="1.27" data-path="Tutorial_180723_Machine_learning.html">
<a href="Tutorial_180723_Machine_learning.html">
기계학습의 기초(지도학습/비지도학습/머신러닝)
</a>
</li>
<li class="chapter " data-level="1.28" data-path="Tutorial_180723_word_vectorsization.html">
<a href="Tutorial_180723_word_vectorsization.html">
텍스트 데이터 시각화 Word_vectorsization
</a>
</li>
<li class="chapter " data-level="1.29" data-path="Tutorial_180726_naver.html">
<a href="Tutorial_180726_naver.html">
특강 - AI R&D Director
</a>
</li>
<li class="chapter " data-level="1.30" data-path="Tutorial_180726_library.md">
<span>
전국도서관표준데이터 분석
</a>
</li>
<li class="chapter " data-level="1.31" data-path="Tutorial_180730_Categorizing_v2.html">
<a href="Tutorial_180730_Categorizing_v2.html">
국민청원 카테고리 분류하기
</a>
</li>
<li class="chapter " data-level="1.32" data-path="Tutorial_180730_Kaggle_NLP_v2.html">
<a href="Tutorial_180730_Kaggle_NLP_v2.html">
Kaggle NLP로 예측율 높이기
</a>
</li>
<li class="chapter " data-level="1.33" data-path="Tutorial_180730_Statistics.html">
<a href="Tutorial_180730_Statistics.html">
Hypothesis test
</a>
</li>
<li class="chapter " data-level="1.34" data-path="Tutorial_180731_MTPlanning.html">
<a href="Tutorial_180731_MTPlanning.html">
데잇걸즈 MT 계획으로 애자일 프로세스 실습해보기
</a>
</li>
<li class="chapter " data-level="1.35" data-path="Tutorial_180802_ZigZag.html">
<a href="Tutorial_180802_ZigZag.html">
특강 - 쇼핑몰 데이터 분석 이야기
</a>
</li>
<li class="chapter " data-level="1.36" data-path="Tutorial_180803_GettingJobGithub.html">
<a href="Tutorial_180803_GettingJobGithub.html">
깃허브로 취업하기
</a>
</li>
<li class="chapter " data-level="1.37" data-path="Tutorial_180803_Statistics4.html">
<a href="Tutorial_180803_Statistics4.html">
회귀분석(Linear regression)
</a>
</li>
<li class="chapter " data-level="1.38" data-path="Tutorial_180806_Folium_practice.md">
<span>
공공데이터 상권정보 분석해 보기
</a>
</li>
<li class="chapter " data-level="1.39" data-path="Tutorial_180806_Geolocatin_API_practice.md">
<span>
서울창업허브(공덕역) 맛집지도
</a>
</li>
<li class="chapter " data-level="1.40" data-path="Tutorial_180806_XGBoost.md">
<span>
XGBoost 분산형 그래디언트 부스팅 알고리즘
</a>
</li>
<li class="chapter " data-level="1.41" data-path="Tutorial_180807_Git_review.html">
<a href="Tutorial_180807_Git_review.html">
깃과 깃헙 복습, 다른 사람의 레파지토리에 기여하기
</a>
</li>
<li class="chapter " data-level="1.42" data-path="Tutorial_180810_Apt_analysis_Statistics5.html">
<a href="Tutorial_180810_Apt_analysis_Statistics5.html">
아파트 분양가 분석 및 회귀분석2
</a>
</li>
<li class="chapter " data-level="1.43" data-path="Tutorial_180813_kaggle_Titanic.html">
<a href="Tutorial_180813_kaggle_Titanic.html">
스프레드시트로 캐글 타이타닉 참가하기
</a>
</li>
<li class="chapter " data-level="1.44" data-path="Tutorial_180814_Python_Class.html">
<a href="Tutorial_180814_Python_Class.html">
객체지향 프로그래밍
</a>
</li>
<li class="chapter " data-level="1.45" data-path="Tutorial_180814_Test_Driven_Development.html">
<a href="Tutorial_180814_Test_Driven_Development.html">
테스트 주도 개발
</a>
</li>
<li class="chapter " data-level="1.46" data-path="Tutorial_180817_Colors_in_Data_Visualization.md">
<span>
데이터 시각화와 색의 활용
</a>
</li>
<li class="chapter " data-level="1.47" data-path="Tutorial_180817_Statistics5.html">
<a href="Tutorial_180817_Statistics5.html">
통계-회귀분석3
</a>
</li>
<li class="divider"></li>
<li>
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
Published with GitBook
</a>
</li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<!-- Title -->
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i>
<a href="." >저작권과 직업윤리를 인지하고 크롤링 셔플 실습</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<div id="book-search-results">
<div class="search-noresults">
<section class="normal markdown-section">
<h1 id="크롤링1">크롤링1</h1>
<h2 id="shuffle함수-과제-리뷰">shuffle함수 과제 리뷰</h2>
<h5 id="기억할-것-">[ 기억할 것 ]</h5>
<p>코드 작성은 설명이나 이름을 붙여주지 않아도 의도가 드러나도록 간결하게 짜는게 중요하다 </p>
<p>파이썬 함수 이름은 소문자와 _의 조합으로 쓰는게 좋다 e.g. sort_by_len()</p>
<p>파이썬은 대소문자를 구분하는 언어이다 (=Case Sensitive 언어)</p>
<ul>
<li><p>rnadom.shuffle()을 이용하는 방법</p>
<p>```python
import random</p>
</li>
</ul>
<p> def shuffle(data):
copied = data[:]
random.shuffle(copied)
return copied</p>
<p> data = [1, 2, 3, 4, 5]
copied = shuffle(data)
copied</p>
<pre><code>
>여기서 random.shuffle 에 data를 바로 입력하지 않고 copied를 정의한 후 copied를 입력하는 이유는 원본 데이터의 변형을 포함하지 않고 shuffle을 진행하기 위함이다.
>
>따라서 data[:]로 data를 복사하여 copied를 생성한다.
+ random.sample()을 이용한 방법
비복원 임의추출 방식 활용
(data를 데이터 갯수만큼 샘플링해서 임의로 가져오는 방식. 한 번 뽑으면 다시 뽑히지 않음)
```python
import random
data = [1, 2, 3, 4, 5, 6]
random.sample(data, len(data))
</code></pre><blockquote>
<p>여기서 마지막 코드를 random.sample(date, 6)으로 짤때, 6은 'magic number'가 된다.</p>
<p>만약 어떠한 수정 작업으로 인해 data길이가 수정된다면, random.sample(data,수정된 data길이)로 매번 바꿔줘야 한다. </p>
<p>random.sample(data, len(date))로 작성한다면 magic number로 인한 비효율성을 제거할 수 있다. </p>
</blockquote>
<ul>
<li><p>Fisher-Yates sampling의 방식</p>
<p>Ronald Fisher와 Frank Yates가 1938에 <statistical tables="" for="" biological,="" agricultural="" and="" medical="" research="">에서 소개한 절차. “난수표"랑 종이와 연필이 필요.
></statistical></p>
<blockquote>
<p><strong><a href="https://exceptionnotfound.net/understanding-the-fisher-yates-card-shuffling-algorithm/" target="_blank">Fisher-Yates sampling 참고 페이지</a> 'Visualizing the Original Method' 에서 시각적으로 어떤 과정을 통해 sampling이 이뤄지는지 알 수 있음</strong></p>
</blockquote>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> random <span class="hljs-keyword">import</span> randint
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">shuffle3</span><span class="hljs-params">(data)</span>:</span>
new_list = data.copy()
result = []
x = <span class="hljs-number">0</span>
<span class="hljs-keyword">for</span> x <span class="hljs-keyword">in</span> range(len(data)):
index = (randint(<span class="hljs-number">0</span>, len(new_list) - <span class="hljs-number">1</span>))
result.append(new_list[index])
<span class="hljs-keyword">del</span> new_list[index]
print(result)
shuffle3([<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>])
</code></pre>
</li>
</ul>
<ul>
<li><p>랜덤 요소를 끌어와서 적용시키는 방식</p>
<p>실제 세상으로부터 노이즈(현재 시간, 마우스 위치, 베터리 잔량, 키보드 입력 패턴 등등)를 끌어와서 랜덤 요소로 쓰는 시도가 많이 있음</p>
<pre><code class="lang-python"><span class="hljs-comment"># 현재 시간을 이용한 랜덤</span>
<span class="hljs-keyword">import</span> time
data = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-number">6</span>, <span class="hljs-number">7</span>, <span class="hljs-number">8</span>, <span class="hljs-number">9</span>, <span class="hljs-number">10</span>]
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">shuffle1</span><span class="hljs-params">(data)</span>:</span>
now = int(time.time())
random = now % <span class="hljs-number">10</span>
result = data.copy()
length = len(data)<span class="hljs-number">-1</span>
<span class="hljs-keyword">for</span> num <span class="hljs-keyword">in</span> range(length) :
temp = result[num]
result[num] = result[length - random]
result[length-random] = temp
<span class="hljs-keyword">return</span> result
print(<span class="hljs-string">'shuffle '</span>, shuffle1(data))
print(<span class="hljs-string">'원본 '</span>, data)
</code></pre>
</li>
</ul>
<h2 id="인터넷-웹-웹브라우저-html-개념알기">인터넷, 웹, 웹브라우저, HTML 개념알기</h2>
<p><strong>개념정리</strong></p>
<ul>
<li><p>인터넷 : 컴퓨터 네트워크들 간의 네트워크(<strong>inter-net</strong>work)</p>
</li>
<li><p>웹(WWW) : HTTP;hypertext transfer protocol(하이퍼텍스트를 전송하는 프로토콜)로 통신하는 컴퓨터들의네트워크 </p>
<blockquote>
<p><a href="https://www.youtube.com/watch?v=J8hzJxb0rpc" target="_blank">참고 : 인터넷과 웹, 웹 브라우저</a></p>
</blockquote>
<ul>
<li><p>URL(Uniform Resource Locator): protocol://user@host:port/path?query#fragment 형식 </p>
<pre><code class="lang-http">https://www.google.com/search?q=test
</code></pre>
</li>
<li><p>Hyperlink : 링크가 걸린 텍스트</p>
</li>
<li><p>Hypertext : 하이퍼링크가 담겨져 있는 텍스트 (ex. 구글 검색화면) </p>
</li>
<li><p>HTML (HyperText Markup Language) : 하이퍼텍스트를 작성하기 위한 언어 중 하나 </p>
</li>
</ul>
</li>
<li><p>웹브라우저 : "사용자 대리인(user agent)"의 일종</p>
<p>인간이 컴퓨터말로 직접 다 말을 걸 수 없기 때문에 사람들이 입력하는 내용(아마도 구현된 웹 인터페이스 상에서 클릭을 한다거나 텍스트를 입력한다거나...)을 받아 컴퓨터의 HTTP응답으로 바꾸고 그를 해석하여 인간에게 보여주는 역할을 함.</p>
</li>
<li><p>DOS 공격
흔히 도스 공격이라고 하는 얘기를 뉴스에서 가끔 들을 수 있는데 이는 서버가 처리할 수 있는 양 이상을 보내서 서버가 과부화되는 현상을 의미한다. 예를 들면, 은행 업무를 마비시키기 위해 10000원을 10원 단위로 수백명이 인출하려고 한다고 생각해보자. 이렇게 되면 한번에 처리할 수 있는 업무량을 월등히 초월해버리기 때문에 시스템이 마비된다. 이런 원리를 서버에 적용한다고 볼 수 있다. </p>
</li>
<li><p>아스키코드와 utf-8
아스키(ASCII)는 영문 알파벳을 사용하는 대표적인 문자 인코딩이다. 아스키는 컴퓨터와 통신 장비를 비롯한 문자를 사용하는 많은 장치에서 사용되며, 대부분의 문자 인코딩이 아스키에 기초를 두고 있다.
알파벳에 기초하고 있기 때문에 그보다 많은 양의 문자를 필요로 하는 한글은 아스키만으로는 표현하기 어렵다. 한글을 출력하기 위해선 utf-8인코딩 방식이 필요하다. UTF-8은 Universal Coded Character Set + Transformation Format – 8-bit 의 약자로 말 그대로 라틴계열의 문자 이외의 수많은 언어를 표현하기 위해 1바이트만 사용하는 아스키와는 다르게 1바이트에서 4바이트까지 사용한다. </p>
</li>
</ul>
<h1 id="데이터-가져오기">데이터 가져오기</h1>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> urllib <span class="hljs-keyword">import</span> request
<span class="hljs-comment">#request라는 파이썬 오픈 함수중에 urllib라는 함수를 호출하는 것</span>
<span class="hljs-comment">#url라이브러리에서 리퀘스트를 import하겠다</span>
<span class="hljs-comment">#import : 다른사람들이 만들어놓은 python 코드를 불러오는 것</span>
url = <span class="hljs-string">"http://www.naver.com"</span>
<span class="hljs-keyword">with</span> request.urlopen(url) <span class="hljs-keyword">as</span> f:
<span class="hljs-comment">#with request.urlopen(url) as f : request.urlopen(url)에서 만든 자원을 f에 할당하고 다 쓴 다음에는 자원을 해제하기 위해 쓰인다.</span>
<span class="hljs-comment">#f는 file의 약자.</span>
html = f.read().decode(<span class="hljs-string">'utf-8'</span>)
<span class="hljs-comment">#read() : http 리퀘스트를 보내고 응답으로 받은것을 읽어온다. 그 응답은 바이트로 온다.</span>
<span class="hljs-comment">#뭐.뭐.뭐 의 형식을 chaining이라고 함 </span>
<span class="hljs-comment">#바이트를 스트링으로 디코딩해주는 것은 decode()</span>
print(html)
</code></pre>
<ul>
<li><p>위계 : 라이브러리 > 패키지 > 모듈 > 함수</p>
<blockquote>
<p> urllib = 패키지</p>
<p>request = urllib 패키지 안에있는 모듈</p>
<p>urlopen() = urllib package 안에 있는 request module 안에 있는 함수</p>
<p>경로로 표현해 보면 위계는 다음과 같다 </p>
<p> <strong>urllib/request/urlopen()</strong> </p>
<p>파이썬라이브러리는 패키지들을 모아둔 것 </p>
<p>(파이썬 표준 라이브러리는 파이썬 설치할 때 들어있음. )</p>
</blockquote>
</li>
</ul>
<h1 id="저작권과-직업윤리">저작권과 직업윤리</h1>
<p><strong>직업윤리</strong></p>
<ul>
<li>부당한 차별 : 차별적 발언을 한 의도는 중요하지 않고 결과가 중요하다.(?) 동일한 발언이라 하더라도 사회역사적 맥락이 중요하다. 같은 발언이라도 어떤사회에 어떤역사의 어떤 맥락에서 하면 부당한 차별이 되는지. --> when is discrimination wrong?</li>
</ul>
<p><strong>저작권</strong></p>
<ul>
<li><p>우리가 만드는 코드에도 저작권이 있고, 코드 실행결과 나오는 데이터, 프로그램으로 가공해서 파생된 데이터의 저작권도 중요하다.</p>
</li>
<li><p>별도로 라이선스에 대한 설명이 없으면 저작자에게 물어보아야 한다. 이 데이터를 이러이러한 용도로 쓰려고 하는데 써도 되겠는가 허락을 맡아야 한다.</p>
</li>
<li><p>거의 모든 컨텐츠에는 어딘가 보면 저작권 관련 문구가 있다.</p>
</li>
<li><p>저작권표시 참고 <a href="http://cckorea.org/xe/elements" target="_blank">http://cckorea.org/xe/elements</a></p>
</li>
<li><p>로봇배제프로토콜 : 누군가 크롤러를 만들어서 데이터를 긁어가려고 하면 여기를 참고하세요라는 의도로 만들어진것</p>
<pre><code>User-agent: * # 모든 유저에이전트는
Disallow: / # 루트디렉토리부터 모두 불허용
</code></pre><p>청와대 사이트는 허용가능하게 해놓았음</p>
</li>
</ul>
</section>
</div>
<div class="search-results">
<div class="has-results">
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
<ul class="search-results-list"></ul>
</div>
<div class="no-results">
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
</div>
</div>
</div>
</div>
</div>
</div>
<a href="Tutorial_180713_ExperimentDesignLecture.html" class="navigation navigation-prev " aria-label="Previous page: 특강-실험계획에 관해 알아보기">
<i class="fa fa-angle-left"></i>
</a>
<a href="Tutorial_180716_Markup_Html5lib.html" class="navigation navigation-next " aria-label="Next page: Markup Html5lib, 파이썬으로 크롤링하기">
<i class="fa fa-angle-right"></i>
</a>
</div>
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"저작권과 직업윤리를 인지하고 크롤링 셔플 실습","level":"1.19","depth":1,"next":{"title":"Markup Html5lib, 파이썬으로 크롤링하기","level":"1.20","depth":1,"path":"Tutorial_180716_Markup_Html5lib.md","ref":"Tutorial_180716_Markup_Html5lib.md","articles":[]},"previous":{"title":"특강-실험계획에 관해 알아보기","level":"1.18","depth":1,"path":"Tutorial_180713_ExperimentDesignLecture.md","ref":"Tutorial_180713_ExperimentDesignLecture.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{"BASE_URL":"https://dataitgirls2.github.io"},"plugins":["ga","-sharing"],"pluginsConfig":{"ga":{"configuration":"auto","token":"UA-43356518-7"},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"Tutorial_180716_Crawling_Shuffle.md","mtime":"2018-07-28T22:58:53.191Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-09-09T04:41:47.437Z"},"basePath":".","book":{"language":""}});
});
</script>
</div>
<script src="gitbook/gitbook.js"></script>
<script src="gitbook/theme.js"></script>
<script src="gitbook/gitbook-plugin-ga/plugin.js"></script>
<script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
<script src="gitbook/gitbook-plugin-search/search.js"></script>
<script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
<script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
<script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
</body>
</html>