質問編集履歴
1
コード書き忘れ
title
CHANGED
File without changes
|
body
CHANGED
@@ -3,4 +3,69 @@
|
|
3
3
|
しかし組み合わせると上手く実行できずエラーを吐いてしまいます。
|
4
4
|
|
5
5
|
python初学者なので分かりやすく解説いただけると幸いです。
|
6
|
-
よろしくお願いいたします。
|
6
|
+
よろしくお願いいたします。
|
7
|
+
|
8
|
+
###定時
|
9
|
+
```python
|
10
|
+
import datetime
|
11
|
+
import schedule
|
12
|
+
import time
|
13
|
+
|
14
|
+
def job():
|
15
|
+
print(datetime.datetime.now())
|
16
|
+
print("I'm working...")
|
17
|
+
|
18
|
+
schedule.every().day.at("14:25").do(job)
|
19
|
+
|
20
|
+
while True:
|
21
|
+
schedule.run_pending()
|
22
|
+
time.sleep(60)
|
23
|
+
```
|
24
|
+
###スクレイピング
|
25
|
+
```python
|
26
|
+
from selenium import webdriver
|
27
|
+
import chromedriver_binary
|
28
|
+
from selenium.webdriver.common.by import By
|
29
|
+
from selenium.webdriver.common.keys import Keys
|
30
|
+
import time
|
31
|
+
|
32
|
+
|
33
|
+
driver = webdriver.Chrome()
|
34
|
+
driver.get('http://○○.jp/');
|
35
|
+
|
36
|
+
time.sleep(3)
|
37
|
+
driver.find_element_by_css_selector("a.buttonMypagelogin").click()
|
38
|
+
time.sleep(3)
|
39
|
+
|
40
|
+
driver.find_element_by_xpath('//*[@id="loginInner_u"]').send_keys("○○○○")
|
41
|
+
driver.find_element_by_xpath('//*[@id="loginInner_p"]').send_keys("○○○○")
|
42
|
+
driver.find_element_by_css_selector("input.loginButton").click()
|
43
|
+
time.sleep(3)
|
44
|
+
driver.find_element_by_css_selector("span.balancedisplay_list_label").click()
|
45
|
+
time.sleep(3)
|
46
|
+
|
47
|
+
driver.get('http://○○○○');
|
48
|
+
driver.find_element_by_xpath('//*[@id="depositingInputPrice"]').send_keys("○○")
|
49
|
+
driver.find_element_by_css_selector("span.confirm").click()
|
50
|
+
time.sleep(3)
|
51
|
+
```
|
52
|
+
###LINE通知
|
53
|
+
```python
|
54
|
+
import requests
|
55
|
+
|
56
|
+
def main():
|
57
|
+
send_line_notify('Success')
|
58
|
+
|
59
|
+
def send_line_notify(notification_message):
|
60
|
+
"""
|
61
|
+
LINEに通知する
|
62
|
+
"""
|
63
|
+
line_notify_token = '○○○○'
|
64
|
+
line_notify_api = 'https://notify-api.line.me/api/notify'
|
65
|
+
headers = {'Authorization': f'Bearer {line_notify_token}'}
|
66
|
+
data = {'message': f'message: {notification_message}'}
|
67
|
+
requests.post(line_notify_api, headers = headers, data = data)
|
68
|
+
|
69
|
+
if __name__ == "__main__":
|
70
|
+
main()
|
71
|
+
```
|