質問編集履歴

1

コード書き忘れ

2020/10/24 22:21

投稿

TomF
TomF

スコア4

test CHANGED
File without changes
test CHANGED
@@ -9,3 +9,133 @@
9
9
  python初学者なので分かりやすく解説いただけると幸いです。
10
10
 
11
11
  よろしくお願いいたします。
12
+
13
+
14
+
15
+ ###定時
16
+
17
+ ```python
18
+
19
+ import datetime
20
+
21
+ import schedule
22
+
23
+ import time
24
+
25
+
26
+
27
+ def job():
28
+
29
+ print(datetime.datetime.now())
30
+
31
+ print("I'm working...")
32
+
33
+
34
+
35
+ schedule.every().day.at("14:25").do(job)
36
+
37
+
38
+
39
+ while True:
40
+
41
+ schedule.run_pending()
42
+
43
+ time.sleep(60)
44
+
45
+ ```
46
+
47
+ ###スクレイピング
48
+
49
+ ```python
50
+
51
+ from selenium import webdriver
52
+
53
+ import chromedriver_binary
54
+
55
+ from selenium.webdriver.common.by import By
56
+
57
+ from selenium.webdriver.common.keys import Keys
58
+
59
+ import time
60
+
61
+
62
+
63
+
64
+
65
+ driver = webdriver.Chrome()
66
+
67
+ driver.get('http://○○.jp/');
68
+
69
+
70
+
71
+ time.sleep(3)
72
+
73
+ driver.find_element_by_css_selector("a.buttonMypagelogin").click()
74
+
75
+ time.sleep(3)
76
+
77
+
78
+
79
+ driver.find_element_by_xpath('//*[@id="loginInner_u"]').send_keys("○○○○")
80
+
81
+ driver.find_element_by_xpath('//*[@id="loginInner_p"]').send_keys("○○○○")
82
+
83
+ driver.find_element_by_css_selector("input.loginButton").click()
84
+
85
+ time.sleep(3)
86
+
87
+ driver.find_element_by_css_selector("span.balancedisplay_list_label").click()
88
+
89
+ time.sleep(3)
90
+
91
+
92
+
93
+ driver.get('http://○○○○');
94
+
95
+ driver.find_element_by_xpath('//*[@id="depositingInputPrice"]').send_keys("○○")
96
+
97
+ driver.find_element_by_css_selector("span.confirm").click()
98
+
99
+ time.sleep(3)
100
+
101
+ ```
102
+
103
+ ###LINE通知
104
+
105
+ ```python
106
+
107
+ import requests
108
+
109
+
110
+
111
+ def main():
112
+
113
+ send_line_notify('Success')
114
+
115
+
116
+
117
+ def send_line_notify(notification_message):
118
+
119
+ """
120
+
121
+ LINEに通知する
122
+
123
+ """
124
+
125
+ line_notify_token = '○○○○'
126
+
127
+ line_notify_api = 'https://notify-api.line.me/api/notify'
128
+
129
+ headers = {'Authorization': f'Bearer {line_notify_token}'}
130
+
131
+ data = {'message': f'message: {notification_message}'}
132
+
133
+ requests.post(line_notify_api, headers = headers, data = data)
134
+
135
+
136
+
137
+ if __name__ == "__main__":
138
+
139
+ main()
140
+
141
+ ```