Last active
April 13, 2022 10:01
-
-
Save YinAoXiong/075e8bb94a0e08f6091d4cda079b55ca to your computer and use it in GitHub Desktop.
一个nexushd批量魔力值兑换上传量的脚本
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from urllib import request | |
import urllib | |
import time | |
def exchange( | |
cookie: str, times: int = 1, environment: str = "v4", sleep_times: float = 0.5 | |
): | |
"""批量使用魔力值兑换上传量的函数 | |
Args: | |
cookie (str): N 站的coookie | |
times (int, optional): 兑换的次数,可以根据魔力值镜像计算 魔力值//1400. Defaults to 1. | |
environment (str, optional): 用户当前使用的环境,默认为ipv4环境,ipv6用户可以传入v6参数. Defaults to "v4". | |
sleep_times (float, optional): 每次兑换后休眠的时间,减少服务器的压力. Defaults to 0.5. | |
Raises: | |
ValueError: 如果传入的环境参数不是v4或者v6,则抛出异常 | |
""" | |
if environment == "v4": | |
url = "https://www.nexushd.org/mybonus.php?action=exchange" | |
elif environment == "v6": | |
url = "https://v6.nexushd.org/mybonus.php?action=exchange" | |
else: | |
raise ValueError("Invalid environment") | |
headers = { | |
"cookie": cookie, | |
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36 Edg/99.0.1150.55", | |
} | |
data = {"submit": "交换", "option": "3"} | |
data = urllib.parse.urlencode(data) | |
req = request.Request(url, headers=headers, data=data.encode("utf-8")) | |
for i in range(times): | |
r = request.urlopen(req) | |
time.sleep(sleep_times) | |
if __name__ == "__main__": | |
exchange( | |
"", | |
1, | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment