feat(dockerfile; run): 修改 dockerfile 脚本;chrome 使用 headless 参数
修改 dockerfile 脚本;chrome 使用 headless 参数 Signed-off-by: Ching <loooching@gmail.com>
This commit is contained in:
parent
c7463b378d
commit
63186e4bdc
2
.gitignore
vendored
2
.gitignore
vendored
@ -7,6 +7,8 @@ __pycache__/
|
|||||||
# C extensions
|
# C extensions
|
||||||
*.so
|
*.so
|
||||||
|
|
||||||
|
last_id.txt
|
||||||
|
|
||||||
# Distribution / packaging
|
# Distribution / packaging
|
||||||
.Python
|
.Python
|
||||||
build/
|
build/
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
FROM selenium/standalone-chrome
|
FROM selenium/standalone-chrome
|
||||||
|
|
||||||
ADD . /app
|
COPY . /app
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
RUN sudo apt update
|
RUN sudo apt update
|
||||||
RUN sudo apt install -y python3-pip
|
RUN sudo apt install -y python3-pip
|
||||||
RUN pip3 install -r requirements.txt
|
RUN pip3 install -r requirements.txt
|
||||||
|
|
||||||
CMD ["python3", "main.py"]
|
ENTRYPOINT ["python3", "main.py"]
|
||||||
|
|||||||
@ -1,2 +1,5 @@
|
|||||||
107896829133801546
|
107896829133801546
|
||||||
107897040775908429
|
107897040775908429
|
||||||
|
107897463271547378
|
||||||
|
107897497559464026
|
||||||
|
107897507395948056
|
||||||
|
|||||||
7
main.py
7
main.py
@ -2,6 +2,7 @@ from mastodon import Mastodon
|
|||||||
import argparse
|
import argparse
|
||||||
from selenium import webdriver
|
from selenium import webdriver
|
||||||
from selenium.webdriver.common.by import By
|
from selenium.webdriver.common.by import By
|
||||||
|
from selenium.webdriver.chrome.options import Options
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
@ -18,7 +19,11 @@ def post_fanfou(webdrive_, fanfou_status, images=None):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def run(instance, access_token, fanfou_account, fanfou_password):
|
def run(instance, access_token, fanfou_account, fanfou_password):
|
||||||
chrome = webdriver.Chrome()
|
chrome_options = Options()
|
||||||
|
chrome_options.add_argument('--headless')
|
||||||
|
chrome_options.add_argument('--no-sandbox')
|
||||||
|
chrome_options.add_argument('--disable-dev-shm-usage')
|
||||||
|
chrome = webdriver.Chrome(chrome_options=chrome_options)
|
||||||
# login to fanfou
|
# login to fanfou
|
||||||
chrome.get('https://m.fanfou.com/')
|
chrome.get('https://m.fanfou.com/')
|
||||||
login_name = chrome.find_element(by=By.NAME, value='loginname')
|
login_name = chrome.find_element(by=By.NAME, value='loginname')
|
||||||
|
|||||||
3
run.sh
3
run.sh
@ -1,4 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
source ./env.sh
|
source ./env.sh
|
||||||
docker build -t $YOUR_CONTAINER_NAME .; docker container run -it -v $(pwd):/app $YOUR_CONTAINER_NAME --mastodon-token $M_TOKEN --mastodon-instance $M_INSTANCE --fanfou-account $FF_ACCOUNT --fanfou-password $FF_PASSWORD
|
docker build -t $YOUR_CONTAINER_NAME .
|
||||||
|
docker container run -it -v $(pwd):/app $YOUR_CONTAINER_NAME --mastodon-token $M_TOKEN --mastodon-instance $M_INSTANCE --fanfou-account $FF_ACCOUNT --fanfou-password $FF_PASSWORD
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user