Skip to content

Commit 65e81c9

Browse files
author
shaowei
committed
merge
2 parents f704a73 + f690f5e commit 65e81c9

File tree

4 files changed

+36
-51
lines changed

4 files changed

+36
-51
lines changed

task_service/executor/facebook/exception.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def check_func(self, key_words, wait=3):
226226
iframe = key_words.get("iframe", None) # 查找关键字之前需要切换至的iframe, 类型为list, 其中元素可以为int或str, int代表iframe的索引, str-代表iframe的id.
227227
if not any([css_keywords, xpath_keywords]):
228228
self.exception_type = -1
229-
logger.error("check func keywords is empty.")
229+
logger.warning("check func keywords is empty.")
230230
return False
231231

232232
key_words_type = By.CSS_SELECTOR

task_service/executor/facebook/pc_actions.py

Lines changed: 27 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -356,53 +356,33 @@ def browse_page(self, browse_times=0, distance=0, interval=0, back_top=True):
356356
return self.fb_exp.auto_process(3)
357357

358358

359-
# if __name__ == '__main__':
360-
# filename = '../../resource/facebook_account.txt'
361-
# with open(filename, 'r') as line:
362-
# all_readline = line.readlines()
363-
# for date in all_readline:
364-
# str_info = date.split('---')
365-
# user_account = str(str_info[0]).strip()
366-
# user_password = str(str_info[1]).strip()
367-
#
368-
# # 登陆
369-
# fma = FacebookPCActions(account_info={"account": user_account, "password": user_password}, finger_print={"user_agent": ""}, headless=False)
370-
# if not fma.start_chrome():
371-
# print("start chrome failed")
372-
# fma.set_exception_processor(
373-
# FacebookExceptionProcessor(fma.driver, env="pc", account=fma.account, gender=fma.gender))
374-
# # fma.set_exception_processor()
375-
# res, status = fma.login()
376-
# if not res:
377-
# continue
378-
# cookies = fma.get_cookies()
379-
# print(cookies)
380-
# fma.browse_user_center(3)
381-
# time.sleep(100)
382-
383-
384359
if __name__ == '__main__':
385-
user_account = str(17610069110)
386-
user_password = str("sanmang111..fb").strip()
387-
388-
# 初始化
389-
cookies=[{'domain': '.facebook.com', 'httpOnly': False, 'name': 'presence', 'path': '/', 'secure': True, 'value': 'EDvF3EtimeF1556521496EuserFA21B35381807782A2EstateFDt3F_5b_5dG556521496536CEchFDp_5f1B35381807782F2CC'}, {'domain': '.facebook.com', 'expiry': 1564297494.289986, 'httpOnly': True, 'name': 'fr', 'path': '/', 'secure': True, 'value': '14Cgytn5XS9ADvrMS.AWWAmG4Z8RUATBEoDXsVDoRqB1g.BcxqHO.Is.FzG.0.0.BcxqIW.AWVueXRy'}, {'domain': '.facebook.com', 'expiry': 1564297485.612012, 'httpOnly': True, 'name': 'xs', 'path': '/', 'secure': True, 'value': '31%3AzbNHAuA7vvOB-Q%3A2%3A1556521482%3A-1%3A-1'}, {'domain': '.facebook.com', 'expiry': 1557126281, 'httpOnly': False, 'name': 'dpr', 'path': '/', 'secure': True, 'value': '2'}, {'domain': '.facebook.com', 'expiry': 1619593469.742837, 'httpOnly': True, 'name': 'datr', 'path': '/', 'secure': True, 'value': 'zqHGXKNTrxN8ELHDhr2hXAEo'}, {'domain': '.facebook.com', 'expiry': 1564297485.611967, 'httpOnly': False, 'name': 'c_user', 'path': '/', 'secure': True, 'value': '100035381807782'}, {'domain': '.facebook.com', 'expiry': 1556611487.566037, 'httpOnly': True, 'name': 'spin', 'path': '/', 'secure': True, 'value': 'r.1000651590_b.trunk_t.1556521485_s.1_v.2_'}, {'domain': '.facebook.com', 'expiry': 1557126293, 'httpOnly': False, 'name': 'wd', 'path': '/', 'secure': True, 'value': '1200x754'}, {'domain': '.facebook.com', 'expiry': 1619593485.611922, 'httpOnly': True, 'name': 'sb', 'path': '/', 'secure': True, 'value': 'zqHGXDSVQ0-0sXJTMh0cHnju'}]
390-
391-
fma = FacebookPCActions(account_info={"account": user_account, "password": user_password, "cookies": cookies}, finger_print={"user_agent": ""}, headless=False)
392-
if not fma.start_chrome():
393-
print("start chrome failed")
394-
fma.set_exception_processor(
395-
FacebookExceptionProcessor(fma.driver, env="pc", account=fma.account, gender=fma.gender))
396-
# 登陆
397-
res, status = fma.login()
398-
399-
# 浏览页面
400-
# fma.browse_home()
401-
# 增加好友
402-
# fma.add_friends(["mac", "xiaomi"], 2)
403-
# 发送状态
404-
fma.post_status("wo shi yi zhi xiaoxiaoniao 鸟")
405-
# 用户中心浏览
406-
# fma.browse_user_center()
360+
filename = '../../resource/facebook_account.txt'
361+
with open(filename, 'r') as line:
362+
all_readline = line.readlines()
363+
for date in all_readline:
364+
str_info = date.split('---')
365+
user_account = str(str_info[0]).strip()
366+
user_password = str(str_info[1]).strip()
367+
368+
# 初始化
369+
# cookies=[{'domain': '.facebook.com', 'httpOnly': False, 'name': 'presence', 'path': '/', 'secure': True, 'value': 'EDvF3EtimeF1556521496EuserFA21B35381807782A2EstateFDt3F_5b_5dG556521496536CEchFDp_5f1B35381807782F2CC'}, {'domain': '.facebook.com', 'expiry': 1564297494.289986, 'httpOnly': True, 'name': 'fr', 'path': '/', 'secure': True, 'value': '14Cgytn5XS9ADvrMS.AWWAmG4Z8RUATBEoDXsVDoRqB1g.BcxqHO.Is.FzG.0.0.BcxqIW.AWVueXRy'}, {'domain': '.facebook.com', 'expiry': 1564297485.612012, 'httpOnly': True, 'name': 'xs', 'path': '/', 'secure': True, 'value': '31%3AzbNHAuA7vvOB-Q%3A2%3A1556521482%3A-1%3A-1'}, {'domain': '.facebook.com', 'expiry': 1557126281, 'httpOnly': False, 'name': 'dpr', 'path': '/', 'secure': True, 'value': '2'}, {'domain': '.facebook.com', 'expiry': 1619593469.742837, 'httpOnly': True, 'name': 'datr', 'path': '/', 'secure': True, 'value': 'zqHGXKNTrxN8ELHDhr2hXAEo'}, {'domain': '.facebook.com', 'expiry': 1564297485.611967, 'httpOnly': False, 'name': 'c_user', 'path': '/', 'secure': True, 'value': '100035381807782'}, {'domain': '.facebook.com', 'expiry': 1556611487.566037, 'httpOnly': True, 'name': 'spin', 'path': '/', 'secure': True, 'value': 'r.1000651590_b.trunk_t.1556521485_s.1_v.2_'}, {'domain': '.facebook.com', 'expiry': 1557126293, 'httpOnly': False, 'name': 'wd', 'path': '/', 'secure': True, 'value': '1200x754'}, {'domain': '.facebook.com', 'expiry': 1619593485.611922, 'httpOnly': True, 'name': 'sb', 'path': '/', 'secure': True, 'value': 'zqHGXDSVQ0-0sXJTMh0cHnju'}]
370+
cookies={}
371+
fma = FacebookPCActions(account_info={"account": user_account, "password": user_password, "cookies": cookies}, finger_print={"user_agent": ""}, headless=False)
372+
if not fma.start_chrome():
373+
print("start chrome failed")
374+
fma.set_exception_processor(
375+
FacebookExceptionProcessor(fma.driver, env="pc", account=fma.account, gender=fma.gender))
376+
# 登陆
377+
res, status = fma.login()
378+
379+
# 浏览页面
380+
# fma.browse_home()
381+
# 增加好友
382+
# fma.add_friends(["pig","dog"], 2)
383+
# 发送状态
384+
# fma.post_status("wo shi yi zhi xiaoxiaoniao 鸟")
385+
# 用户中心浏览
386+
fma.browse_user_center()
407387

408388

web_service/vps/view.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,7 @@ def get(self, request):
6262
# result = list(map(lambda item:{item["name"]:item["count"]},ser.data))
6363
# result = {item["name"]:item["count"] for item in ser.data}
6464
ret = json.dumps(ser.data,ensure_ascii=False)
65-
return HttpResponse(ret)
65+
return HttpResponse(ret)
66+
67+
def test_func(self):
68+
print(1111)

web_service/web_service/urls.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
from users.api.user.views import UserViewSet
1414
from vps.view import AreaViewSet, AgentViewSet, AreaAccountCount
1515
from web_service.views import render_page
16-
16+
def abc():
17+
print(122222)
18+
pass
1719
# Routers provide an easy way of automatically determining the URL conf.
1820
router = routers.DefaultRouter()
1921
# vps
@@ -33,7 +35,7 @@
3335

3436
urlpatterns = [
3537
# path('admin/', admin.site.urls),
36-
url(r'^api/areaAccountCount/', AreaAccountCount.as_view()), # 区域账号个数
38+
url(r'^api/areaAccountCount/', AreaAccountCount.as_view(test_func=abc)), # 区域账号个数
3739
url(r'^api/user/', include('users.api.urls')),
3840
url(r'^api/task/sum/', TaskSumView.as_view()),
3941
url(r'^api/', include(router.urls)),

0 commit comments

Comments
 (0)