Browse Source

chore(host): change host from '0.0.0.0' to 'localhost'

master
louisyoungx 3 years ago
parent
commit
a83275fe48
  1. 2
      Config/config.ini
  2. 18
      Core/spider.py
  3. 11
      Server/handler.py
  4. BIN
      Static/img/qr_code.png
  5. BIN
      cookies/Louis_Young.cookies

2
Config/config.ini

@ -84,7 +84,7 @@ DEBUG = False @@ -84,7 +84,7 @@ DEBUG = False
SERVER_NAME = "TinyServer"
SERVER_VERSION = "0.4.8"
START_USING = True
SERVER_HOST = "www.server.com"
SERVER_HOST = "localhost"
LOCAL_HOST = "0.0.0.0"
PORT = 12021
PROCESS_MODEL = False

18
Core/spider.py

@ -76,19 +76,21 @@ class Waiter(): @@ -76,19 +76,21 @@ class Waiter():
"""
用户登陆态校验装饰器若用户未登陆则调用扫码登陆
"""
@ functools.wraps(func)
@functools.wraps(func)
def new_func(self, *args, **kwargs):
if not self.qrlogin.is_login:
logger.info("{0} 需登陆后调用,开始扫码登陆".format(func.__name__))
self.login_by_qrcode()
return func(self, *args, **kwargs)
return new_func
@ check_login
@check_login
def waitForSell(self):
self._waitForSell()
@ check_login
@check_login
def waitTimeForSell(self):
self._waitTimeForSell()
@ -134,7 +136,7 @@ class Waiter(): @@ -134,7 +136,7 @@ class Waiter():
except:
return self.get_sku_title()
@ check_login
@check_login
def waitAndBuy_by_proc_pool(self):
"""
多进程进行抢购
@ -149,9 +151,9 @@ class Waiter(): @@ -149,9 +151,9 @@ class Waiter():
"""
检查是否有货
"""
stockurl = 'http://c0.3.cn/stock?skuId=' + self.skuids +\
'&cat=652,829,854&area=' + self.area +\
'&extraParam={%22originid%22:%221%22}'
stockurl = 'http://c0.3.cn/stock?skuId=' + self.skuids + \
'&cat=652,829,854&area=' + self.area + \
'&extraParam={%22originid%22:%221%22}'
response = self.session.get(stockurl)
resp = self.session.get(stockurl)
jsparser = json.loads(resp.text)

11
Server/handler.py

@ -3,20 +3,20 @@ import os, json, urllib, time @@ -3,20 +3,20 @@ import os, json, urllib, time
from Logger.logger import logger
from http.server import BaseHTTPRequestHandler
from Config.settings import config
# Document https://docs.python.org/3.9/library/http.server.html
from Server.url import urls
# Document https://docs.python.org/3.9/library/http.server.html
class RequestHandler(BaseHTTPRequestHandler):
'''处理请求并返回页面'''
"""处理请求并返回页面"""
# 处理一个GET请求
def do_GET(self):
self.rootPath = config.path() + "/Static"
url = self.requestline[4:-9]
print(url)
request_data = {} # 存放GET请求数据
request_data = {} # 存放GET请求数据
try:
if url.find('?') != -1:
req = url.split('?', 1)[1]
@ -25,7 +25,7 @@ class RequestHandler(BaseHTTPRequestHandler): @@ -25,7 +25,7 @@ class RequestHandler(BaseHTTPRequestHandler):
for i in parameters:
key, val = i.split('=', 1)
request_data[key] = val
#request_data['body'] = self.rfile.read()
# request_data['body'] = self.rfile.read()
except:
logger.error("URL Format Error")
if (url == "/"):
@ -52,7 +52,6 @@ class RequestHandler(BaseHTTPRequestHandler): @@ -52,7 +52,6 @@ class RequestHandler(BaseHTTPRequestHandler):
self.api(url[4:], request_data)
else:
self.file(url)
def log_message(self, format, *args):
SERVER_LOGGER = config.settings("Logger", "SERVER_LOGGER")

BIN
Static/img/qr_code.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 776 B

BIN
cookies/Louis_Young.cookies

Binary file not shown.
Loading…
Cancel
Save