Skip to content

Commit 875276a

Browse files
修改cookies登录
1 parent d8103db commit 875276a

File tree

5 files changed

+38
-9
lines changed

5 files changed

+38
-9
lines changed

task_service/config/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ system:
3434
screenshots_force: 0 # 是否强制在异常时截图,默认为false,代表只有在无头环境下才截图, 开发人员可以选择打开,更改为1即可
3535
screenshots_dir: screenshots # 截图保存目录
3636
screenshots_keep: 5 # 默认保存最近5天的截图
37+
force_display: 0 # 是否强制显示浏览器界面,默认为否
3738

3839
support:
3940
captcha_in_api: "http://2captcha.com/in.php"

task_service/config/config_test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ system:
3434
screenshots_force: 1 # 是否强制在异常时截图,默认为false,代表只有在无头环境下才截图, 开发人员可以选择打开,更改为1即可
3535
screenshots_dir: screenshots # 截图保存目录
3636
screenshots_keep: 10 # 默认保存最近15天的截图
37+
force_display: 0 # 是否强制显示浏览器界面,默认为否
3738

3839
support:
3940
captcha_in_api: "http://2captcha.com/in.php"

task_service/executor/facebook/base_actions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __init__(self, account_info, finger_print={},
2727
self.password = account_info.get("password", "")
2828
self.gender = account_info.get("gender", 1)
2929
self.phone_number = account_info.get("phone_number", "")
30-
self.cookies = account_info.get("cookies", "")
30+
self.cookies = account_info.get("configure", {}).get("cookies", "")
3131
self.start_url = start_url
3232
self.fb_exp = None
3333
super(FacebookActions, self).__init__(finger_print=finger_print, headless=headless)

task_service/start_worker.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,44 @@
6868
import subprocess
6969
env = "pro"
7070
save_log = True
71+
queue_names = "default"
72+
concurrent = 4
7173
input_env = input("Please input execute environment(pro/test):")
7274
if input_env and input_env in ["pro", 'test']:
7375
env = input_env
7476
else:
75-
print("use default env: pro")
77+
print("use default env: {}".format(env))
7678

77-
is_log_file = input("is save log to file(yes/no):")
79+
queue_names_input = input("Please input queue name(separate multiples with commas):")
80+
if queue_names_input:
81+
queue_names = queue_names_input
82+
queue_names = queue_names.replace(' ', '')
83+
else:
84+
print("use default queue: {}".format(queue_names))
85+
86+
concurrent_input = input("Please input concurrent numbers(default:4):")
87+
try:
88+
concurrent = int(concurrent_input)
89+
except:
90+
print("use default concurrent: {}".format(concurrent))
91+
92+
is_log_file = input("Is save log to file(yes/no):")
7893
if is_log_file and is_log_file in ["yes", 'no']:
7994
if "no" in is_log_file:
8095
save_log = False
96+
print("don't save log in file")
97+
else:
98+
print("Save log in file")
99+
else:
100+
print("Save log in file")
81101

82102
if save_log:
83-
subprocess.call("celery -A start_worker -Q default,China,American,Japan worker -l info -c 4 -Ofair -f logs/celery_{}.log -env {}".format(
84-
datetime.datetime.now().strftime("%Y-%m-%d_%H_%M_%S"), env), shell=True)
103+
celery_cmd = "celery -A start_worker -Q {} worker -l info -c {} -Ofair -f logs/celery_{}.log -env {}".format(
104+
queue_names, concurrent, datetime.datetime.now().strftime("%Y-%m-%d_%H_%M_%S"), env)
85105
else:
86-
subprocess.call(
87-
"celery -A start_worker -Q default,China,American,Japan worker -l info -c 4 -Ofair -env {}".format(env), shell=True)
106+
celery_cmd = "celery -A start_worker -Q {} worker -l info -c {} -Ofair -env {}".format(
107+
queue_names, concurrent, env)
108+
109+
print("Celery cmd: {}".format(celery_cmd))
110+
subprocess.call(celery_cmd, shell=True)
88111

task_service/tasks/processor.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import datetime
77
from start_worker import app
88
from db import JobOpt, Job, Task, TaskCategory, Agent, TaskAccountGroup, Account, Scheduler, FingerPrint, Area
9-
from config import logger, get_environment
9+
from config import logger, get_environment, get_system_args
1010
from db.basic import ScopedSession
1111
from sqlalchemy import and_
1212

@@ -124,10 +124,14 @@ def send_task_2_worker(task_id):
124124

125125
active_browser = db_scoped_session.query(FingerPrint.value).filter(FingerPrint.id == active_browser_id).first()
126126

127+
if get_system_args()["force_display"] == 0:
128+
headless = True if get_environment() == 'pro' else False
129+
else:
130+
headless = False
127131
# 构建任务执行必备参数
128132
inputs = {
129133
'system': {
130-
'headless': True if get_environment() == 'pro' else False
134+
'headless': headless
131135
},
132136
'task': {
133137
'task_id': task_id,

0 commit comments

Comments
 (0)