한번에 그리기

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
import plotly
import math
from plotly.graph_objs import Scatter, Layout



t1 = 0 #변수, 상수 선언
t2 = 0
t3 = 0
t4 = 0
g = 9.81
c = 12.5
m = 68.1
delta1 = 0.6
delta2 = 1.2
delta3 = 2.4
vel = 0
vel1 = 0
vel2 = 0
vel3 = 0
vel4 = 0
Ti1 = [0]
Ve1 = [0]
Ti2 = [0]
Ve2 = [0]
Ti3 = [0]
Ve3 = [0]
Ti4 = [0]
Ve4 = [0]


def velocity(vel, delta):
value = vel + (g - c * vel / m) * delta #식의 해
return value

def realsol(t):
Value = 53.44*(1-math.exp(1)**(-0.18355*t))
return Value


for a in range(0, 80): #몇번 반복할지
vel1 = velocity(vel1, delta1)
t1 = t1 + delta1
T1 = round(t1, 1) #유효숫자
VEL1 = round(vel1, 1)
Ti1 = Ti1 + [T1]
Ve1 = Ve1 + [VEL1]

for a in range(0, 40): #몇번 반복할지
vel2 = velocity(vel2, delta2)
t2 = t2 + delta2
T2 = round(t2, 1) #유효숫자
VEL2 = round(vel2, 1)
Ti2 = Ti2 + [T2]
Ve2 = Ve2 + [VEL2]

for a in range(0, 20): #몇번 반복할지
vel3 = velocity(vel3, delta3)
t3 = t3 + delta3
T3 = round(t3, 1) #유효숫자
VEL3 = round(vel3, 1)
Ti3 = Ti3 + [T3]
Ve3 = Ve3 + [VEL3]

for a in range(0, 4800): #몇번 반복할지
vel4 = realsol(t4)
t4 = t4 + 0.01
T4 = round(t4, 1) #유효숫자
VEL4 = round(vel4, 1)
Ti4 = Ti4 + [T4]
Ve4 = Ve4 + [VEL4]


plotly.offline.plot({
"data": [Scatter(x=Ti1, y=Ve1)],
"layout": Layout(title="ODE 풀이, delta = 0.6")
})

plotly.offline.plot({
"data": [Scatter(x=Ti2, y=Ve2)],
"layout": Layout(title="ODE 풀이, delta = 1.2")
})

plotly.offline.plot({
"data": [Scatter(x=Ti3, y=Ve3)],
"layout": Layout(title="ODE 풀이, delta = 2.4")
})

plotly.offline.plot({
"data": [Scatter(x=Ti4, y=Ve4)],
"layout": Layout(title="ODE 풀이, realsol")
})
Read more »

YouTube에서 JTBC로 가기

제목을 따와서 JTBC에 검색하자

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from selenium import webdriver
import time

browser = webdriver.Chrome('C:/Users/OHG/Downloads/chromedriver_win32/chromedriver') #Directory지정
browser.implicitly_wait(5) #암묵적으로 3초 딜레이
url = "https://www.youtube.com/watch?v=C7qr7-NlNw8&index=1&list=PL3Eb1N33oAXijqFKrO83hDEN0HPwaecV3"
ser = "http://jtbc.joins.com/search?term="

browser.get(url)
for a in range(1, 100): #url의 개수
products = browser.find_elements_by_css_selector('#container > h1 > yt-formatted-string')
for product in products:
Z = product.text
print(Z[13:])
time.sleep(3)
browser.quit()

실행결과

1
'One sweet dream'

제목 따오고 ser에 붙여서 검색하자

Read more »

Pytube

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
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pytube
>>> yt = pytube.YouTube("https://www.youtube.com/watch?v=94YwFIJ-yR0&list=PL3Eb1N33oAXijqFKrO83hDEN0HPwaecV3&index=1")
>>> vids = yt.streams.all()
>>> for i in range(len(vids)):
... print(i,':',vids[i])
...
0 : <Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2">
1 : <Stream: itag="43" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp8.0" acodec="vorbis">
2 : <Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2">
3 : <Stream: itag="36" mime_type="video/3gpp" res="240p" fps="30fps" vcodec="mp4v.20.3" acodec="mp4a.40.2">
4 : <Stream: itag="17" mime_type="video/3gpp" res="144p" fps="30fps" vcodec="mp4v.20.3" acodec="mp4a.40.2">
5 : <Stream: itag="136" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.4d401f">
6 : <Stream: itag="247" mime_type="video/webm" res="720p" fps="30fps" vcodec="vp9">
7 : <Stream: itag="135" mime_type="video/mp4" res="480p" fps="30fps" vcodec="avc1.4d401f">
8 : <Stream: itag="244" mime_type="video/webm" res="480p" fps="30fps" vcodec="vp9">
9 : <Stream: itag="134" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.4d401e">
10 : <Stream: itag="243" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp9">
11 : <Stream: itag="133" mime_type="video/mp4" res="240p" fps="30fps" vcodec="avc1.4d4015">
12 : <Stream: itag="242" mime_type="video/webm" res="240p" fps="30fps" vcodec="vp9">
13 : <Stream: itag="160" mime_type="video/mp4" res="144p" fps="30fps" vcodec="avc1.4d400c">
14 : <Stream: itag="278" mime_type="video/webm" res="144p" fps="30fps" vcodec="vp9">
15 : <Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2">
16 : <Stream: itag="171" mime_type="audio/webm" abr="128kbps" acodec="vorbis">
17 : <Stream: itag="249" mime_type="audio/webm" abr="50kbps" acodec="opus">
18 : <Stream: itag="250" mime_type="audio/webm" abr="70kbps" acodec="opus">
19 : <Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus">

영상 정보 퍼오기

Read more »

중력에 대한 ODE를 Numerical analysis

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
t = 0 #변수, 상수 선언
g = 9.81
c = 12.5
m = 68.1
delta = 2.4
vel = 0


def velocity(t):
value = vel + (g - c * vel / m) * delta #식의 해
return value


print(t, vel)

for a in range(1, 100): #몇번 반복할지
vel = velocity(t)
t = t + delta
print(t, vel)
1
2
3
4
5
6
7
8
9
10
11
0 0
2.4 23.544
4.8 36.71619383259912
7.199999999999999 44.085659104581886
9.6 48.208663904325554
12.0 50.51536703017333
14.4 51.80590137811459
#중간생략 왼쪽이 시간, 오른쪽이 Velocity
232.80000000000038 53.44487999999999
235.2000000000004 53.44487999999999
237.6000000000004 53.44487999999999
Read more »