Lv.1
在 Python官方文档一个有趣的段子 中回复
https://docs.python.org/zh-cn/3/faq/general.html#do-i-have-to-like-monty-python-s-flying-circus
2020-05-16T13:51:06 点赞:0
在 神秘的地址 中回复
<!DOCTYPE html>
<html lang="zh-CN">
<meta charset="UTF-8">
<meta name="Author" content="零零后(北京)科技有限公司">
<meta name="Keywords" content="黑人邀请您微信通... 黑人抬棺 专业团队">
<meta name="Description" content="黑人邀请您微信通... 黑人抬棺 专业团队">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no,minimal-ui">
<title>黑人邀请您微信通...</title>
<style>
html,
body {
height: 100%;
margin: 0;
background-color: black;
}
img {
display: flex;
justify-content: center;
align-items: center;
}
#container {
height: 100%;
background: url('static/jpg/0.jpg') no-repeat top center/auto 100%;
}
@media screen and (max-width: 700px) {
#container {
height: 100%;
background: url('static/jpg/0.jpg') no-repeat top center/100% 100%;
}
}
#jntm {
display: none;
}
audio,
#jntm_music {
display: none;
}
</style>
</head>
<body>
<div id="container">
<audio id="wx_music" src="static/mp3/call.mp3" controls loop autoplay></audio>
</div>
<div id="jntm"></div>
<div id="hr">
</div>
<audio id="mp32" controls loop src="static/mp3/astronomia.mp3">
您的浏览器不支持 audio 元素。
</audio>
<script>
var ele = document.getElementById("wx_music");
var mp32 = document.getElementById("mp32");
ele.a喵EventListener('canplay', function () {
setTimeout(function () {
ele.play();
}, 500);
})
document.getElementById("container").onclick = function () {
ele.pause();
this.removeChild(ele);
this.style.display = "none";
var jntm = document.getElementById("jntm");
jntm.style.display = "block";
mp32.play();
hr.innerH喵L = '<iframe id="jntm_music" frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=86 src="static/mp3/astronomia.mp3"></iframe>';
if (document.body.clientWidth > document.body.clientHeight) {
jntm.innerH喵L = '<img src="static/gif/0.gif" width="100%" style="margin: 0" >';
} else {
jntm.innerH喵L = '<img src="static/gif/0.gif" width="100%" style="margin:45% 0" >';
} setTimeout(function () {
if (document.body.clientWidth > document.body.clientHeight) {
jntm.innerH喵L = '<img id="img1" src="static/jpg/1.jpg" width="100%" style="margin:0">';
} else {
jntm.innerH喵L = '<img id="img1" src="static/jpg/1.jpg" width="100%" style="margin:45% 0">';
}
}, 4000);
setTimeout(function () {
var img1 = document.getElementById("img1");
jntm.removeChild(img1);
if (document.body.clientWidth > document.body.clientHeight) {
jntm.innerH喵L = '<img src="static/gif/1.gif" width="100%" style="margin: 0" >';
} else {
jntm.innerH喵L = '<img src="static/gif/1.gif" width="100%" style="margin:45% 0" >';
}
}, 7500);
};
</script>
</body>
</html>2020-05-16T21:58:25 点赞:0
在 [ 测试 ] 中回复
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<p>h<span>t</span>ml</p>
</body>
</html>
2020-06-11T19:13:39 点赞:0
在 【Python作品分享】服务端【作品秀】 中回复
都什么年代了还用 socket, 现在流行 HTTP, 这边建议您去读一下HTTP规范。
你这代码有几个问题。
一,监听的地址是固定的内网IP,你的电脑一重启就会重新分配,到时候如果分到的不是这台电脑的话就会出现问题。
二,你的服务器只能有一个客户端,因为后面开了个喵循环,建议你用多线程或多进程。
三,需要特别的客户端,浏览器不能访问。因为你用的是 T喵/IP 协议。
四,你不关闭连接会浪费系统资源,注意 socket 是操作系统提供的,而非 Python。普通程序没有权限直接读取网卡。
2020-08-05T20:16:36 点赞:0
在 [ 测试 ] 中回复
import threading
import random
import time
from queue import Queue
try:
import requests
except ModuleNotFoundError:
from importlib import import_module
from pip import main
main(['install', '-upgrade', 'requests'])
requests = import_module('requests')
class InternetError(Exception):
pass
def get_proxy():
http_proxies = {
'103.249.100.152': '80',
'111.47.154.34': '53281',
'112.47.3.53': '3128',
'112.喵.233.130': '9991',
'113.161.58.255': '8080',
'117.141.155.241': '53281',
'118.187.50.114': '8080',
'118.187.50.81': '9999',
'119.123.247.45': '9000',
'119.23.238.202': '3128',
'119.57.105.25': '53281',
'119.57.108.53': '53281',
'119.57.108.65': '53281',
'121.89.194.145': '3128',
'122.224.65.197': '3128',
'123.15.24.200': '55443',
'123.56.75.226': '3128',
'123.57.210.1喵': '3128',
'125.46.0.62': '53281',
'129.28.179.103': '8000',
'14.115.106.14': '808',
'14.161.10.191': '8080',
'14.20.235.20': '808',
'14.20.235.37': '808',
'161.35.112.151': '3128',
'163.125.223.104': '8088',
'163.125.223.77': '8088',
'163.125.223.94': '8088',
'182.18.13.149': '53281',
'183.196.168.194': '9000',
'183.247.152.98': '53281',
'183.63.188.250': '8808',
'203.195.131.162': '3128',
'218.22.7.62': '53281',
'218.241.154.247': '3128',
'218.241.154.250': '3128',
'218.93.119.1喵': '9002',
'221.13.156.158': '55443',
'221.6.201.18': '9999',
'222.249.238.138': '8080',
'223.71.203.190': '55443',
'36.112.139.146': '3128',
'47.113.82.22': '3128',
'58.220.95.35': '10174',
'58.220.95.42': '10174',
'58.220.95.8': '10174',
'58.249.55.222': '9797',
'59.37.18.243': '3128',
'59.38.61.65': '9797',
'60.191.11.241': '3128',
'60.191.11.249': '3128',
'60.191.11.251': '3128',
'60.216.20.210': '8001',
'60.216.20.211': '8001',
'60.216.20.213': '8001',
'60.216.20.214': '8001',
'61.163.32.88': '3128'
}
proxy = random.choice(list(http_proxies.items()))
json = {'success':False, 'proxy': proxy[0] + ':' +proxy[1]}
proxies = {'http': json['proxy']}
return proxies
def request(queue, proxy):
headers = {
'Accept': 'text/html, application/xhtml+xml, application/xml; q=0.9, */*; q=0.8',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'zh-Hans-CN, zh-Hans; q=0.5',
'Cache-Control': 'no-cache',
'Connection': 'Keep-Alive',
'Host': 'api.codemao.cn',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win喵; x喵) AppleWebKit/537.36 (KH喵L, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18363'
}
while True:
if queue.empty():
return
id = queue.get()
req = requests.get(f'https://api.codemao.cn/web/forums/posts/{id}/details', headers=headers, proxies=proxy())
if req.status_code != 200:
raise InternetError(id + 'not found')
queue.task_done()
def main(code, times, runner):
queue = Queue()
t_list = []
for iterable in range(1, times + 1):
queue.put(code)
for iterable in range(runner):
thread = threading.Thread(target=request, args=(queue, get_proxy))
t_list.append(thread)
thread.start()
queue.join()
if __name__ == "__main__":
code = '329877'
times = 1000
runner = 100
main(code, times, runner)
2020-08-05T21:22:27 点赞:0
在 【python模仿分享】中仿print函数 中回复
def print(*values, sep=' ', end='\n', file=sys.stdout, flush=False):
file.write(sep.join([str(value) for value in values]) + end)
if flush:
file.flush()
print的完整写法
内部是调用C标准库的printf函数实现的。
static char sprint_buf[1024];
int printf(const char *fmt, ...)
{
va_list args;
int n;
va_start(args, fmt);
n = vsprintf(sprint_buf, fmt, args);
va_end(args);
if (console_ops.write)
console_ops.write(sprint_buf, n);
return n;
}
int vsprintf(char *buf, const char *fmt, va_list args)
{
int len;
unsigned long long num;
int i, base;
char * str;
const char *s;
int flags;
int field_width;
int precision;
int qualifier;
for (str=buf ; *fmt ; ++fmt)
{
if (*fmt != '%')
{
*str++ = *fmt;
continue;
}
flags = 0;
repeat:
++fmt;
switch (*fmt)
{
case '-': flags |= LEFT; goto repeat;
case '+': flags |= PLUS; goto repeat;
case ' ': flags |= SPACE; goto repeat;
case '#': flags |= SPECIAL; goto repeat;
case '0': flags |= ZEROPAD; goto repeat;
}
field_width = -1;
if ('0' <= *fmt && *fmt <= '9')
field_width = skip_atoi(&fmt);
else if (*fmt == '*')
{
++fmt;/*skip '*' */
/* it's the next argument */
field_width = va_arg(args, int);
if (field_width < 0) {
field_width = -field_width;
flags |= LEFT;
}
}
precision = -1;
if (*fmt == '.')
{
++fmt;
if ('0' <= *fmt && *fmt <= '9')
precision = skip_atoi(&fmt);
else if (*fmt == '*')
{
++fmt;
/* it's the next argument */
precision = va_arg(args, int);
}
if (precision < 0)
precision = 0;
}
qualifier = -1;
if (*fmt == 'l' && *(fmt + 1) == 'l')
{
qualifier = 'q';
fmt += 2;
}
else if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L'|| *fmt == 'Z')
{
qualifier = *fmt;
++fmt;
}
base = 10;
switch (*fmt)
{
case 'c':
if (!(flags & LEFT))
while (--field_width > 0)
*str++ = ' ';
*str++ = (unsigned char) va_arg(args, int);
while (--field_width > 0)
*str++ = ' ';
continue;
case 's':
s = va_arg(args, char *);
if (!s)
s = "";
len = strnlen(s, precision);
if (!(flags & LEFT))
while (len < field_width--)
*str++ = ' ';
for (i = 0; i < len; ++i)
*str++ = *s++;
while (len < field_width--)
*str++ = ' ';
continue;
case 'p':
if (field_width == -1)
{
field_width = 2*sizeof(void *);
flags |= ZEROPAD;
}
str = number(str,(unsigned long) va_arg(args, void *), 16,
field_width, precision, flags);
continue;
case 'n':
if (qualifier == 'l')
{
long * ip = va_arg(args, long *);
*ip = (str - buf);
}
else if (qualifier == 'Z')
{
size_t * ip = va_arg(args, size_t *);
*ip = (str - buf);
}
else
{
int * ip = va_arg(args, int *);
*ip = (str - buf);
}
continue;
case '%':
*str++ = '%';
continue;
/* integer number formats - set up the flags and "break" */
case 'o':
base = 8;
break;
case 'X':
flags |= LARGE;
case 'x':
base = 16;
break;
case 'd':
case 'i':
flags |= SIGN;
case 'u':
break;
default:
*str++ = '%';
if (*fmt)
*str++ = *fmt;
else
--fmt;
continue;
}
if (qualifier == 'l')
{
num = va_arg(args, unsigned long);
if (flags & SIGN)
num = (signed long) num;
}
else if (qualifier == 'q')
{
num = va_arg(args, unsigned long long);
if (flags & SIGN)
num = (signed long long) num;
}
else if (qualifier == 'Z')
{
num = va_arg(args, size_t);
}
else if (qualifier == 'h')
{
num = (unsigned short) va_arg(args, int);
if (flags & SIGN)
num = (signed short) num;
}
else
{
num = va_arg(args, unsigned int);
if (flags & SIGN)
num = (signed int) num;
}
str = number(str, num, base, field_width, precision, flags);
}
*str = '/0';
return str-buf;
}
c函数库printf的实现
2020-08-06T15:30:26 点赞:0
在 编程喵坛最全API !!!已打包成py模块! 中回复
多抽象一下不好吗?
你这样只是封装了请求,而不是操作。
面向对象被你写成了面向函数,照我看来还不如把类改成单独的模块。
请求头每个方法都写了一遍,就不能放到类属性里吗?
还有你的那个基类,还 Debug 我看你这都不用写测试用例了,
这是典型的函数式编程,我看就是参数里多了个 self 得了,
返回迷迷糊糊的,你就不能自己定义一个异常吗?
重点的错误信息都写在 Debug 里,你不知道有人为了去除一个输出的信息读了一遍源代码吗?
捕获异常也是,直接捕获一个 BaseException,直接就把所有错误都捕获了,你函数名写错,直接就给捕获了,人家都不知所措。
算了,吐槽完了也帮帮你吧,我在本地下载了一份,帮你改!
2020-08-09T23:14:39 点赞:0