diff --git a/.gitignore b/.gitignore index f8b73e7..5745d50 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,8 @@ __pycache__/ # C extensions *.so +last_id.txt + # Distribution / packaging .Python build/ diff --git a/Dockerfile b/Dockerfile index 99a0c15..677be5d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,10 @@ FROM selenium/standalone-chrome -ADD . /app - +COPY . /app WORKDIR /app RUN sudo apt update RUN sudo apt install -y python3-pip RUN pip3 install -r requirements.txt -CMD ["python3", "main.py"] +ENTRYPOINT ["python3", "main.py"] diff --git a/last_id.txt b/last_id.txt index 1c89816..791b53f 100644 --- a/last_id.txt +++ b/last_id.txt @@ -1,2 +1,5 @@ 107896829133801546 107897040775908429 +107897463271547378 +107897497559464026 +107897507395948056 diff --git a/main.py b/main.py index 097c5a8..f5a2fc6 100644 --- a/main.py +++ b/main.py @@ -2,6 +2,7 @@ from mastodon import Mastodon import argparse from selenium import webdriver from selenium.webdriver.common.by import By +from selenium.webdriver.chrome.options import Options import time @@ -18,7 +19,11 @@ def post_fanfou(webdrive_, fanfou_status, images=None): pass 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 chrome.get('https://m.fanfou.com/') login_name = chrome.find_element(by=By.NAME, value='loginname') diff --git a/run.sh b/run.sh index a0fd671..1be2e82 100755 --- a/run.sh +++ b/run.sh @@ -1,4 +1,5 @@ #!/bin/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