增加CICD
This commit is contained in:
110
spider/task.py
110
spider/task.py
@@ -1,19 +1,24 @@
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
import random
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
import uuid
|
||||
import json
|
||||
import random
|
||||
import requests
|
||||
import threading
|
||||
import sys
|
||||
import os
|
||||
|
||||
import pyotp
|
||||
from const import MIMETYPE, BUCKET, PIC_TYPE, BASE_PATH, api_url
|
||||
from miniofile import client, put_object
|
||||
from exceptions import AuthException, OperationFailed
|
||||
from playwright.sync_api import sync_playwright, Error, TimeoutError
|
||||
import pywintypes
|
||||
import requests
|
||||
import win32api
|
||||
import win32con
|
||||
from PIL import ImageGrab
|
||||
from lxml import html
|
||||
from playwright.sync_api import sync_playwright, Error, TimeoutError
|
||||
|
||||
from const import BUCKET, BASE_PATH
|
||||
from exceptions import AuthException, OperationFailed
|
||||
from logger import error_logger
|
||||
from miniofile import client, put_object
|
||||
|
||||
|
||||
# def get_dtsg_token(cookies):
|
||||
@@ -720,10 +725,6 @@ def _full_screenshot():
|
||||
def update_windows_distinguish(x=1920, y=1080):
|
||||
"""更改windows分辨率"""
|
||||
if sys.platform == "win32":
|
||||
import win32api
|
||||
import win32con
|
||||
import pywintypes
|
||||
|
||||
devmode = pywintypes.DEVMODEType()
|
||||
|
||||
# screenSize = [1280,800]
|
||||
@@ -782,40 +783,45 @@ def parse_cookies(cookies):
|
||||
|
||||
|
||||
def check_account_status(page, cookies):
|
||||
# 检查是否失效
|
||||
error_logger.info(f"page Title == {page.title()}")
|
||||
if page.title() != "Facebook":
|
||||
raise AuthException('该账号状态已失效', 'invalid')
|
||||
|
||||
# 检查是否冻结
|
||||
headers = {
|
||||
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
|
||||
'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8',
|
||||
'cache-control': 'max-age=0',
|
||||
'dpr': '2',
|
||||
'priority': 'u=0, i',
|
||||
'referer': 'https://www.facebook.com/',
|
||||
'sec-ch-prefers-color-scheme': 'light',
|
||||
'sec-ch-ua': '"Chromium";v="134", "Not:A-Brand";v="24", "Google Chrome";v="134"',
|
||||
'sec-ch-ua-full-version-list': '"Chromium";v="134.0.6998.89", "Not:A-Brand";v="24.0.0.0", "Google Chrome";v="134.0.6998.89"',
|
||||
'sec-ch-ua-mobile': '?0',
|
||||
'sec-ch-ua-model': '""',
|
||||
'sec-ch-ua-platform': '"macOS"',
|
||||
'sec-ch-ua-platform-version': '"15.3.2"',
|
||||
'sec-fetch-dest': 'document',
|
||||
'sec-fetch-mode': 'navigate',
|
||||
'sec-fetch-site': 'same-origin',
|
||||
'sec-fetch-user': '?1',
|
||||
'upgrade-insecure-requests': '1',
|
||||
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36',
|
||||
'viewport-width': '743',
|
||||
}
|
||||
cookies = {i['name']: i['value'] for i in cookies}
|
||||
uid = cookies['c_user']
|
||||
url = f"https://graph.facebook.com/{uid}/picture?type=normal"
|
||||
response = requests.get(url, headers=headers, allow_redirects=False)
|
||||
if response.status_code == 302:
|
||||
if response.headers.get('Location') == 'https://static.xx.fbcdn.net/rsrc.php/v1/yh/r/C5yt7Cqf3zU.jpg':
|
||||
raise AuthException('该账号已被冻结', 'frozen')
|
||||
try:
|
||||
_change_language(page)
|
||||
except TimeoutError:
|
||||
headers = {
|
||||
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
|
||||
'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8',
|
||||
'cache-control': 'max-age=0',
|
||||
'dpr': '2',
|
||||
'priority': 'u=0, i',
|
||||
'referer': 'https://www.facebook.com/',
|
||||
'sec-ch-prefers-color-scheme': 'light',
|
||||
'sec-ch-ua': '"Chromium";v="134", "Not:A-Brand";v="24", "Google Chrome";v="134"',
|
||||
'sec-ch-ua-full-version-list': '"Chromium";v="134.0.6998.89", "Not:A-Brand";v="24.0.0.0", "Google Chrome";v="134.0.6998.89"',
|
||||
'sec-ch-ua-mobile': '?0',
|
||||
'sec-ch-ua-model': '""',
|
||||
'sec-ch-ua-platform': '"macOS"',
|
||||
'sec-ch-ua-platform-version': '"15.3.2"',
|
||||
'sec-fetch-dest': 'document',
|
||||
'sec-fetch-mode': 'navigate',
|
||||
'sec-fetch-site': 'same-origin',
|
||||
'sec-fetch-user': '?1',
|
||||
'upgrade-insecure-requests': '1',
|
||||
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36',
|
||||
'viewport-width': '743',
|
||||
}
|
||||
cookies = {i['name']: i['value'] for i in cookies}
|
||||
uid = cookies['c_user']
|
||||
url = f"https://graph.facebook.com/{uid}/picture?type=normal"
|
||||
response = requests.get(url, headers=headers, allow_redirects=False)
|
||||
if response.status_code == 302:
|
||||
if response.headers.get('Location') == 'https://static.xx.fbcdn.net/rsrc.php/v1/yh/r/C5yt7Cqf3zU.jpg':
|
||||
raise AuthException('该账号已被冻结', 'frozen')
|
||||
else:
|
||||
raise OperationFailed('操作超时或该账户异常,请重试')
|
||||
raise OperationFailed('操作超时或该账户异常,请重试')
|
||||
|
||||
|
||||
class RLock(threading._RLock):
|
||||
@@ -1120,9 +1126,7 @@ def playwright_check_account_cookies(cookies):
|
||||
page = context.new_page()
|
||||
url = 'https://www.facebook.com'
|
||||
page.goto(url)
|
||||
time.sleep(1)
|
||||
page.goto(url)
|
||||
time.sleep(10)
|
||||
time.sleep(3)
|
||||
check_account_status(page, parse_cookies(cookies))
|
||||
context.close()
|
||||
browser.close()
|
||||
@@ -1254,8 +1258,8 @@ if __name__ == '__main__':
|
||||
# # lastname='Keals',
|
||||
# # image_key='rg.jpg'
|
||||
# )
|
||||
# cookies = '{"datr": "AywLaEqnpuloEMFZFDsT2M_n", "sb": "AywLaHIpk4AHGJP1Fd9c9QFY", "locale": "en_US", "wd": "1920x945", "c_user": "61575694132528", "fr": "0uwYJ79B5B5QtHQlb.AWfITZg5T5P_nadNOxtrCjnArAa3M3q_nhI96McABALXYwpB55A.BoCywD..AAA.0.0.BoCywS.AWdWYvZYad3s8s25sh3-a_oZsxU", "xs": "12%3AJmqcjLatZzjPoQ%3A2%3A1745562643%3A-1%3A-1"}'
|
||||
# playwright_check_account_cookies(cookies)
|
||||
cookies = playwright_login('61575694132528', '@Badhon@20', 'LK3UVPADNOEGWIWPBAWWVGDPCMJOZN7M')
|
||||
print(cookies)
|
||||
cookies = '{"c_user":"61565823476070","datr":"q13hZowje6bbViFxECQpYyp8","fr":"01C6Lt4VArm5hELvx.AWXg75HOo-QNJgbiDl8qFtw_5lc.Bm4V2r..AAA.0.0.Bm4V25.AWWHzUeMTuI","m_pixel_ratio":"1.875","sb":"q13hZgJARsRIDmNJG8xUauAe","wd":"384x686","xs":"50%3A8luhgQ-Ea0vnhg%3A2%3A1726045627%3A-1%3A-1"}'
|
||||
playwright_check_account_cookies(cookies)
|
||||
# cookies = playwright_login('61575694132528', '@Badhon@20', 'LK3UVPADNOEGWIWPBAWWVGDPCMJOZN7M')
|
||||
# print(cookies)
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user