Browse Source

add xhs

master
zhangwen 2 weeks ago
commit
3dc5ec465c
  1. 8
      xhs/.idea/.gitignore
  2. 34
      xhs/.idea/inspectionProfiles/Project_Default.xml
  3. 6
      xhs/.idea/inspectionProfiles/profiles_settings.xml
  4. 7
      xhs/.idea/misc.xml
  5. 8
      xhs/.idea/modules.xml
  6. 8
      xhs/.idea/xhs.iml
  7. 31
      xhs/1.html
  8. 43
      xhs/1.json
  9. BIN
      xhs/1.png
  10. BIN
      xhs/__pycache__/image_up.cpython-310.pyc
  11. BIN
      xhs/__pycache__/sing.cpython-310.pyc
  12. 208
      xhs/image_up.py
  13. 8
      xhs/js/.idea/.gitignore
  14. 34
      xhs/js/.idea/inspectionProfiles/Project_Default.xml
  15. 6
      xhs/js/.idea/inspectionProfiles/profiles_settings.xml
  16. 8
      xhs/js/.idea/js.iml
  17. 4
      xhs/js/.idea/misc.xml
  18. 8
      xhs/js/.idea/modules.xml
  19. 68
      xhs/js/a1.js
  20. 1644
      xhs/js/common.js
  21. 14
      xhs/js/main.js
  22. 90
      xhs/js/main.py
  23. 1312
      xhs/js/mnsv2.js
  24. 11
      xhs/js/t.js
  25. 143
      xhs/js/补环境/huanjing.js
  26. 972
      xhs/js/补环境/mnsv2.js
  27. 196
      xhs/js/补环境/proxies.js
  28. 3588
      xhs/js/补环境/qtr.js
  29. 4
      xhs/js/补环境/run.js
  30. 1504
      xhs/js/补环境/ttt.js
  31. 1282
      xhs/js/补环境/webpack.js
  32. 0
      xhs/js/补环境/x9.js
  33. 103
      xhs/main.py
  34. 96
      xhs/sing.py
  35. 51
      xhs/t.py

8
xhs/.idea/.gitignore

@ -0,0 +1,8 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

34
xhs/.idea/inspectionProfiles/Project_Default.xml

@ -0,0 +1,34 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<Languages>
<language minSize="113" name="Python" />
</Languages>
</inspection_tool>
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredPackages">
<value>
<list size="16">
<item index="0" class="java.lang.String" itemvalue="chromadb" />
<item index="1" class="java.lang.String" itemvalue="langchain_chroma" />
<item index="2" class="java.lang.String" itemvalue="langchain-openai" />
<item index="3" class="java.lang.String" itemvalue="customtkinter" />
<item index="4" class="java.lang.String" itemvalue="nltk" />
<item index="5" class="java.lang.String" itemvalue="sentence-transformers" />
<item index="6" class="java.lang.String" itemvalue="typing-extensions" />
<item index="7" class="java.lang.String" itemvalue="requests" />
<item index="8" class="java.lang.String" itemvalue="keybert" />
<item index="9" class="java.lang.String" itemvalue="langchain-community" />
<item index="10" class="java.lang.String" itemvalue="openai" />
<item index="11" class="java.lang.String" itemvalue="google-generativeai" />
<item index="12" class="java.lang.String" itemvalue="google-ai-generativelanguage" />
<item index="13" class="java.lang.String" itemvalue="azure-ai-inference" />
<item index="14" class="java.lang.String" itemvalue="langchain" />
<item index="15" class="java.lang.String" itemvalue="langchain-core" />
</list>
</value>
</option>
</inspection_tool>
</profile>
</component>

6
xhs/.idea/inspectionProfiles/profiles_settings.xml

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

7
xhs/.idea/misc.xml

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.10" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10" project-jdk-type="Python SDK" />
</project>

8
xhs/.idea/modules.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/xhs.iml" filepath="$PROJECT_DIR$/.idea/xhs.iml" />
</modules>
</component>
</project>

8
xhs/.idea/xhs.iml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.10" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

31
xhs/1.html

@ -0,0 +1,31 @@
<div data-v-3fd7f6dc="" class="publish-page-publish-btn">
<button data-v-1f5d204c="" data-v-3fd7f6dc="" type="button"
class="d-button d-button-default d-button-with-content --color-static bold --color-bg-fill --color-text-paragraph custom-button white">
<div class="d-button-content"><!----><span
class="d-text --color-static --color-current --size-text-paragraph d-text-nowrap d-text-ellipsis d-text-nowrap"
style="text-underline-offset: auto;"><!---->暂存离开<!----><!----><!----></span><!----></div>
</button>
<button data-v-1f5d204c="" data-v-3fd7f6dc="" type="button"
class="d-button d-button-default d-button-with-content --color-static bold --color-bg-fill --color-text-paragraph custom-button bg-red">
<div class="d-button-content"><!----><span
class="d-text --color-static --color-current --size-text-paragraph d-text-nowrap d-text-ellipsis d-text-nowrap"
style="text-underline-offset: auto;"><!---->发布<!----><!----><!----></span><!----></div>
</button>
</div>
<div data-v-3fd7f6dc="" class="publish-page-publish-btn">
<button data-v-1f5d204c="" data-v-3fd7f6dc="" type="button"
class="d-button d-button-default d-button-with-content --color-static bold --color-bg-fill --color-text-paragraph custom-button white">
<div class="d-button-content"><!----><span
class="d-text --color-static --color-current --size-text-paragraph d-text-nowrap d-text-ellipsis d-text-nowrap"
style="text-underline-offset: auto;"><!---->暂存离开<!----><!----><!----></span><!----></div>
</button>
<button data-v-1f5d204c="" data-v-3fd7f6dc="" type="button"
class="d-button d-button-default disabled d-button-with-content --color-static bold --color-bg-fill --color-text-disabled custom-button bg-red disabled"
disabled="">
<div class="d-button-content"><!----><span
class="d-text --color-static --color-current --size-text-paragraph d-text-nowrap d-text-ellipsis d-text-nowrap"
style="text-underline-offset: auto;"><!---->发布<!----><!----></span><!----></div>
</button>
</div>

43
xhs/1.json

@ -0,0 +1,43 @@
{
"code": 0,
"success": true,
"data": {
"result": {
"success": true
},
"uploadTempPermits": [
{
"token": "7nwEhfwZCyghEUbr6yE0etToWSY:eyJkZWFkbGluZSI6MTc3Mjk0NjIxNSwiYWxsb3dQcmVmaXhlcyI6WyJoXzhSMkFhMmp6OFNrQXZGczN4cTh6WHA2c19lY3hLVFhNOVNaTHZScEtvWXZLRSJdfQ",
"uploadAddr": "ros-upload.xiaohongshu.com",
"fileIds": [
"spectrum/h_8R2Aa2jz8SkAvFs3xq8zXp6s_ecxKTXM9SZLvRpKoYvKE"
],
"uploadId": 80,
"storageType": 1,
"currentTime": 1772859815685,
"expireTime": 1772946215685,
"qos": 2,
"cloudType": 4,
"bucket": "unknown",
"region": "unknown",
"startTime": 1772859815685
},
{
"token": "7-NkslCzzE2RNnhO5ag6WbDJDho:eyJkZWFkbGluZSI6MTc3Mjk0NjIxNSwiYWxsb3dQcmVmaXhlcyI6WyI3RXF3RWo1bXU0VmxpUU5rM2ZDbXZkVll3Z3pHaG5WekxfRUY3TGQxb2VoLUtKOCJdfQ",
"uploadAddr": "ros-upload-d4.xhscdn.com",
"qos": 1,
"fileIds": [
"spectrum/7EqwEj5mu4VliQNk3fCmvdVYwgzGhnVzL_EF7Ld1oeh-KJ8"
],
"startTime": 1772859815685,
"currentTime": 1772859815685,
"expireTime": 1772946215685,
"cloudType": 4,
"bucket": "unknown",
"region": "unknown",
"uploadId": 403,
"storageType": 5
}
]
}
}

BIN
xhs/1.png

After

Width: 462  |  Height: 126  |  Size: 6.4 KiB

BIN
xhs/__pycache__/image_up.cpython-310.pyc

BIN
xhs/__pycache__/sing.cpython-310.pyc

208
xhs/image_up.py

@ -0,0 +1,208 @@
import json
import time
from urllib.parse import urlparse
import requests
import execjs
from sing import get_auth
eval_js = execjs.compile(open(r'D:\2026-3\xhs\js\main.js', 'r', encoding='utf-8').read())
def get_a1():
a1 = eval_js.eval('generateLocalId()')
return a1
def get_x_s(url, data=None):
u = urlparse(url)
result = u.path
if u.query != "":
result += "?" + u.query
if data:
result += json.dumps(data, ensure_ascii=False)
x_s = eval_js.call('xhs_x_s', result)
else:
x_s = eval_js.call('xhs_x_s', result)
return x_s
def get_common(a1, b1):
x_s = eval_js.call('get_common', a1, b1)
return x_s
def get_x_t():
return str(int(time.time() * 1000))
def get_headers(cookie, url, data=None):
headers = {
"accept": "application/json, text/plain, */*",
"accept-language": "zh-CN,zh;q=0.9",
"authorization;": "",
"cache-control": "no-cache",
"pragma": "no-cache",
"priority": "u=1, i",
"referer": "https://creator.xiaohongshu.com/publish/publish?source=official&from=tab_switch",
"sec-ch-ua": "\"Chromium\";v=\"9\", \"Not?A_Brand\";v=\"8\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"Windows\"",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 SLBrowser/9.0.6.8151 SLBChan/10 SLBVPV/64-bit",
"x-s": get_x_s(url, data),
"x-s-common": get_common(cookie['a1'], ''),
"x-t": get_x_t(),
}
return headers
cookies = {
"a1": get_a1(),
"webId": "f2675311fd5ef2666e15073ef7876bb9",
"gid": "yjWf8S8JKJ7qyjWf8S8JJW6j2fJ0xSVhJ6fYvW61Y1A09828yWy69U888yy2jKY8YY0Yjf0i",
"x-user-id-ark.xiaohongshu.com": "6861bde9000000001e01790f",
"customerClientId": "706990196683713",
"x-user-id-fuwu.xiaohongshu.com": "6861bde9000000001e01790f",
"abRequestId": "f2675311fd5ef2666e15073ef7876bb9",
"web_session": "040069769f151fb684b60b65903b4b342673dc",
"id_token": "VjEAAApbUkDez1irEIDK8Xskk9WfmyF6jSocgzGzSSzuhxM1cdthEiup4YdxvB5E6aGLqvdW7DvcwGDBYIbfs0G2mejs1Wf5kYkdDCpD2bFo46Gu3EprnI8se/nm/lE80TPlBClU",
"customer-sso-sid": "68c517612540944882532354dbfxgoivhkkgdhc5",
"x-user-id-creator.xiaohongshu.com": "5a0457e4db2e6045e3f6d4e0",
"access-token-creator.xiaohongshu.com": "customer.creator.AT-68c517612540944882532355njwip1rjvzxfmmyi",
"galaxy_creator_session_id": "hMLkZfiS1vCMl6Ls1unn7AdCJN1EQuNkVHCZ",
"galaxy.creator.beaker.session.id": "1772432808364005045757",
"webBuild": "5.14.0",
"unread": "{%22ub%22:%2269a568c4000000001b01d337%22%2C%22ue%22:%22699edff00000000028008ccc%22%2C%22uc%22:25}",
"acw_tc": "0a0d096b17728479400813507e65716b1f67026c1556a667d2cbd8eef79b3a",
"xsecappid": "ugc",
"loadts": "1772847946657",
"websectiga": "9730ffafd96f2d09dc024760e253af6ab1feb0002827740b95a255ddf6847fc8",
"sec_poison_id": "e52f4379-6e82-42d0-8133-d806bcc4d280"
}
def get_file():
url = 'https://creator.xiaohongshu.com/api/media/v1/upload/creator/permit?biz_name=spectrum&scene=image&file_count=1&version=1&source=web'
response = requests.get(url, headers=get_headers(cookie=cookies, url=url), cookies=cookies)
return response.json()
def put_data(fileid, token):
with open('1.png', 'rb') as p:
data = p.read()
t = str(int(time.time()))
auth = get_auth({
"SecretId": "null",
"SecretKey": "null",
"Method": "PUT",
"Pathname": fileid,
"Query": {},
"Headers": {
"Content-Length": len(data),
"Host": "ros-upload.xiaohongshu.com"
},
"KeyTime": f"{t};{t}",
"UseRawKey": False
})
print(auth)
url = f'https://ros-upload.xiaohongshu.com/{fileid}'
headers = {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Accept-Language": "zh-CN,zh;q=0.9",
"Authorization": auth,
"Cache-Control": "",
"Content-Type": "",
"Origin": "https://creator.xiaohongshu.com",
"Pragma": "no-cache",
"Priority": "u=1, i",
"Referer": "https://creator.xiaohongshu.com/",
"Sec-Ch-Ua": "\"Chromium\";v=\"9\", \"Not?A_Brand\";v=\"8\"",
"Sec-Ch-Ua-Mobile": "?0",
"Sec-Ch-Ua-Platform": "\"Windows\"",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-site",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 SLBrowser/9.0.6.8151 SLBChan/10 SLBVPV/64-bit",
"X-Cos-Security-Token": token
}
res = requests.put(url=url, headers=headers, data=data).text
print('-------------', res)
def new(file_id):
url = "https://edith.xiaohongshu.com/web_api/sns/v2/note"
data = {
"common": {
"type": "normal",
"note_id": "",
"source": "{\"type\":\"web\",\"ids\":\"\",\"extraInfo\":\"{\\\"subType\\\":\\\"official\\\",\\\"systemId\\\":\\\"web\\\"}\"}",
"title": "11",
"desc": "22",
"ats": [],
"hash_tag": [],
"business_binds": "{\"version\":1,\"noteId\":0,\"bizType\":0,\"noteOrderBind\":{},\"notePostTiming\":{},\"noteCollectionBind\":{\"id\":\"\"},\"noteSketchCollectionBind\":{\"id\":\"\"},\"coProduceBind\":{\"enable\":true},\"noteCopyBind\":{\"copyable\":true},\"interactionPermissionBind\":{\"commentPermission\":0},\"optionRelationList\":[]}",
"privacy_info": {
"op_type": 1,
"type": 0,
"user_ids": []
},
"goods_info": {},
"biz_relations": [],
"capa_trace_info": {
"contextJson": "{\"recommend_title\":{\"recommend_title_id\":\"\",\"is_use\":3,\"used_index\":-1},\"recommendTitle\":[],\"recommend_topics\":{\"used\":[]}}"
}
},
"image_info": {
"images": [
{
"file_id": file_id,
"width": 3442,
"height": 4590,
"metadata": {
"source": -1
},
"stickers": {
"version": 2,
"floating": []
},
"extra_info_json": "{\"mimeType\":\"image/png\",\"image_metadata\":{\"bg_color\":\"\",\"origin_size\":1282.61328125}}"
}
]
},
"video_info": None
}
# data_raw = '{"common":{"type":"normal","note_id":"","source":"{\\"type\\":\\"web\\",\\"ids\\":\\"\\",\\"extraInfo\\":\\"{\\\\\\"subType\\\\\\":\\\\\\"official\\\\\\",\\\\\\"systemId\\\\\\":\\\\\\"web\\\\\\"}\\"}","title":"111","desc":"222","ats":[],"hash_tag":[],"business_binds":"{\\"version\\":1,\\"noteId\\":0,\\"bizType\\":0,\\"noteOrderBind\\":{},\\"notePostTiming\\":{},\\"noteCollectionBind\\":{\\"id\\":\\"\\"},\\"noteSketchCollectionBind\\":{\\"id\\":\\"\\"},\\"coProduceBind\\":{\\"enable\\":true},\\"noteCopyBind\\":{\\"copyable\\":true},\\"interactionPermissionBind\\":{\\"commentPermission\\":0},\\"optionRelationList\\":[]}","privacy_info":{"op_type":1,"type":0,"user_ids":[]},"goods_info":{},"biz_relations":[],"capa_trace_info":{"contextJson":"{\\"recommend_title\\":{\\"recommend_title_id\\":\\"\\",\\"is_use\\":3,\\"used_index\\":-1},\\"recommendTitle\\":[],\\"recommend_topics\\":{\\"used\\":[]}}"}},"image_info":{"images":[{"file_id":"spectrum/KLpGPJCvUHX1KUGCjYgq2pG_pgnnovE6c-1snNb8CKYNOo8","width":3024,"height":4032,"metadata":{"source":-1},"stickers":{"version":2,"floating":[]},"extra_info_json":"{\\"mimeType\\":\\"image/png\\",\\"image_metadata\\":{\\"bg_color\\":\\"\\",\\"origin_size\\":1745.205078125}}"}]},"video_info":null}'
headers = get_headers(cookies, url, data)
response = requests.post(url, headers=headers, cookies=cookies, json=data)
print(response.text)
# def get_file_url():
# url = "https://www.xiaohongshu.com/web_api/sns/v5/creator/file/encryption?file_id=%2Fspectrum%2FQfyQUONtYxXAxO16o8dxSipox7U8UonPCJu9hvYHLq5AjrI&type=image&ts=1772869510861&sign=0f37b5816f1a65c43087554236326cf3"
# response = requests.get(url, headers=get_headers(cookies,url,), cookies=cookies, params=params)
#
# print(response.text)
# print(response)
def run():
file = get_file()
print(file)
fileid = file['data']['uploadTempPermits'][0]['fileIds'][0]
token = file['data']['uploadTempPermits'][0]['token']
put_data(fileid, token)
new(fileid)
if __name__ == '__main__':
run()

8
xhs/js/.idea/.gitignore

@ -0,0 +1,8 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

34
xhs/js/.idea/inspectionProfiles/Project_Default.xml

@ -0,0 +1,34 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<Languages>
<language minSize="113" name="Python" />
</Languages>
</inspection_tool>
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredPackages">
<value>
<list size="16">
<item index="0" class="java.lang.String" itemvalue="chromadb" />
<item index="1" class="java.lang.String" itemvalue="langchain_chroma" />
<item index="2" class="java.lang.String" itemvalue="langchain-openai" />
<item index="3" class="java.lang.String" itemvalue="customtkinter" />
<item index="4" class="java.lang.String" itemvalue="nltk" />
<item index="5" class="java.lang.String" itemvalue="sentence-transformers" />
<item index="6" class="java.lang.String" itemvalue="typing-extensions" />
<item index="7" class="java.lang.String" itemvalue="requests" />
<item index="8" class="java.lang.String" itemvalue="keybert" />
<item index="9" class="java.lang.String" itemvalue="langchain-community" />
<item index="10" class="java.lang.String" itemvalue="openai" />
<item index="11" class="java.lang.String" itemvalue="google-generativeai" />
<item index="12" class="java.lang.String" itemvalue="google-ai-generativelanguage" />
<item index="13" class="java.lang.String" itemvalue="azure-ai-inference" />
<item index="14" class="java.lang.String" itemvalue="langchain" />
<item index="15" class="java.lang.String" itemvalue="langchain-core" />
</list>
</value>
</option>
</inspection_tool>
</profile>
</component>

6
xhs/js/.idea/inspectionProfiles/profiles_settings.xml

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

8
xhs/js/.idea/js.iml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

4
xhs/js/.idea/misc.xml

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (js_rpc_drive-main)" project-jdk-type="Python SDK" />
</project>

8
xhs/js/.idea/modules.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/js.iml" filepath="$PROJECT_DIR$/.idea/js.iml" />
</modules>
</component>
</project>

68
xhs/js/a1.js

@ -0,0 +1,68 @@
var CHARSET = "abcdefghijklmnopqrstuvwxyz1234567890";
_const__WEBPACK_IMPORTED_MODULE_36__ = {}
_encrypt__WEBPACK_IMPORTED_MODULE_34__ = {}
_const__WEBPACK_IMPORTED_MODULE_36__.MU = 0
_encrypt__WEBPACK_IMPORTED_MODULE_34__.QR = function (a) {
for (var e, c = [], f = 0; f < 256; f++) {
e = f;
for (var d = 0; d < 8; d++)
e = 1 & e ? 0xedb88320 ^ e >>> 1 : e >>> 1;
c[f] = e
}
for (var t = -1, n = 0; n < a.length; n++)
t = t >>> 8 ^ c[255 & (t ^ a.charCodeAt(n))];
return (-1 ^ t) >>> 0
};
function genRandomString(a) {
return Array(a).fill(void 0).map(function () {
return CHARSET[Math.floor(36 * Math.random())]
}).join("")
}
PlatformCode = {
"0": "Windows",
"1": "iOS",
"2": "Android",
"3": "MacOs",
"4": "Linux",
"5": "other",
"Windows": 0,
"iOS": 1,
"Android": 2,
"MacOs": 3,
"Linux": 4,
"other": 5
}
function getPlatformCode(a) {
switch (a) {
case "Android":
return PlatformCode.Android;
case "iOS":
return PlatformCode.iOS;
case "Mac OS":
return PlatformCode.MacOs;
case "Linux":
return PlatformCode.Linux;
default:
return PlatformCode.other
}
}
function generateLocalId(a) {
var e = getPlatformCode(a)
, c = "000"
,
f = "".concat((+new Date).toString(16)).concat(genRandomString(30)).concat(e).concat(_const__WEBPACK_IMPORTED_MODULE_36__.MU).concat(c)
, d = (0,
_encrypt__WEBPACK_IMPORTED_MODULE_34__.QR)(f);
return "".concat(f).concat(d).substring(0, 52)
}
// console.log(generateLocalId('Windows'))
module.exports = {
generateLocalId: generateLocalId
}

1644
xhs/js/common.js
File diff suppressed because it is too large
View File

14
xhs/js/main.js

@ -0,0 +1,14 @@
try {
require('./mnsv2.js')
var {get_common, xhs_x_s} = require('./common.js')
var {generateLocalId} = require('./a1')
} catch {
require('D:/2026-3/xhs/js/mnsv2.js')
var {get_common, xhs_x_s} = require('D:/2026-3/xhs/js//common.js')
var {generateLocalId} = require('D:/2026-3/xhs/js//a1')
}
console.log(xhs_x_s('aa'))
// console.log(get_common(x5="197d0c0225d2ahcjv2md8l8lqat171mtu7y0pm97m50000115968",x8="I38rHdgsjopgIvesdVwgIC+oIELmBZ5e3VwXLgFTIxS3bqwErFeexd0ekncAzMFYnqthIhJeSnMDKutRI3KsYorWHPtGrbV0P9WfIi/eWc6eYqtyQApPI37ekmR1QLQ5Ii6sdneeSfqYHqwl2qt5B0DBIx+PGDi/sutkIxdsxuwr4qtiIhuaIE3e3LV0I3VTIC7e0utl2ADmsLveDSKsSPw5IEvsiVtJOqw8BuwfPpdeTFWOIx4TIiu6ZPwrPut5IvlaLbgs3qtxIxes1VwHIkumIkIyejgsY/WTge7eSqte/D7sDcpipedeYrDtIC6eDVw2IENsSqtlnlSuNjVtIvoekqt3cZ7sVo4gIESyIhE4H9quIxhnqz8gIkIfoqwkICZWG73sdlOeVPw3IvAe0fged0lGIi5s3IcM2utAIiKsidvekZNeTPt4nAOeWPwEIvYaaA7eSuw5gfesDqwoI38rIxE5Luwwaqw+rekhZANe1MNe0Pw9ICNsVLoeSbIFIkosSr7sVnFiIk/sVVwHIvln/PtCcPwpIEos0uwQIv5e6utsI3de1VwsnVtlyqtsIkSLICHr27lk2Iee1utCIESwIE6sjqtnzIzrcnNsYjYuIihLGutzrutlIv5ekqtUOpKs1rNexZusIhveYzAs1qwLButwIxoeWVt7IkgexjRwIveeSd/efVtSIxds1uwU8oToIhI4IvJs1SgeTn7eYMgsSPtsIkq1Ixz6aPtcIC4jIE7s6FqSwnvs0VtsIhpBbut14lNedMgeYuwpmPwZIiF8IEE+sutzwuwhI30sWzAekPwwcVtgICk0eVtcIir9PYZhIxds6Les3FNe0qwFsVt7IxiuIiesYqtQIvveTgTsIEbiwj4UIhE5IEAeYqw7qutWbPtpIkLZIC7s0WveWqwcKBZ4IEPMcVt5QPtMIkFlIibxIxEGIv/eS9AsfnkyrVwfIEq8yuwhOVwrIvgefMh/I3FfGrge6PtcOut5+0HAtpryI3YcquwlI3dsWaQhIxYMHqwBIxpWtut+HVtWICDcIhlJIhkutPwoIxDjIv/sYVwQNs8aIvqWIE5sTgvsSutjICPlIiVMncrgIx+hsZ4CIv7sDdeejVwtIh7sxPtJIEcHIh3sDuwmIv+n+qw5IC/sTlVocutEHqtPIC6efqteIhesVLbYIEKsYM5sYVtnQU7sYVwysdNsTVtLIx/sVlAe3qwrIhV="
// ))

90
xhs/js/main.py

@ -0,0 +1,90 @@
import time
from urllib.parse import urlparse
import requests
import execjs
eval_js = execjs.compile(open('main.js', 'r', encoding='utf-8').read())
def get_a1():
a1 = eval_js.eval('generateLocalId()')
return a1
def get_x_s(url, data=None):
u = urlparse(url)
result = u.path + "?" + u.query
if data:
x_s = eval_js.call('xhs_x_s', result, data)
else:
x_s = eval_js.call('xhs_x_s', result)
return x_s
def get_common(a1, b1):
x_s = eval_js.call('get_common', a1, b1)
return x_s
def get_x_t():
return str(int(time.time() * 1000))
def get_headers(cookie, url):
headers = {
"accept": "application/json, text/plain, */*",
"accept-language": "zh-CN,zh;q=0.9",
"authorization;": "",
"cache-control": "no-cache",
"pragma": "no-cache",
"priority": "u=1, i",
"referer": "https://creator.xiaohongshu.com/publish/publish?source=official&from=tab_switch",
"sec-ch-ua": "\"Chromium\";v=\"9\", \"Not?A_Brand\";v=\"8\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"Windows\"",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 SLBrowser/9.0.6.8151 SLBChan/10 SLBVPV/64-bit",
"x-s": get_x_s(url),
"x-s-common": get_common(cookie['a1'], ''),
"x-t": get_x_t(),
}
return headers
cookies = {
"a1": get_a1(),
"webId": "f2675311fd5ef2666e15073ef7876bb9",
"gid": "yjWf8S8JKJ7qyjWf8S8JJW6j2fJ0xSVhJ6fYvW61Y1A09828yWy69U888yy2jKY8YY0Yjf0i",
"x-user-id-ark.xiaohongshu.com": "6861bde9000000001e01790f",
"customerClientId": "706990196683713",
"x-user-id-fuwu.xiaohongshu.com": "6861bde9000000001e01790f",
"abRequestId": "f2675311fd5ef2666e15073ef7876bb9",
"web_session": "040069769f151fb684b60b65903b4b342673dc",
"id_token": "VjEAAApbUkDez1irEIDK8Xskk9WfmyF6jSocgzGzSSzuhxM1cdthEiup4YdxvB5E6aGLqvdW7DvcwGDBYIbfs0G2mejs1Wf5kYkdDCpD2bFo46Gu3EprnI8se/nm/lE80TPlBClU",
"customer-sso-sid": "68c517612540944882532354dbfxgoivhkkgdhc5",
"x-user-id-creator.xiaohongshu.com": "5a0457e4db2e6045e3f6d4e0",
"access-token-creator.xiaohongshu.com": "customer.creator.AT-68c517612540944882532355njwip1rjvzxfmmyi",
"galaxy_creator_session_id": "hMLkZfiS1vCMl6Ls1unn7AdCJN1EQuNkVHCZ",
"galaxy.creator.beaker.session.id": "1772432808364005045757",
"webBuild": "5.14.0",
"unread": "{%22ub%22:%2269a568c4000000001b01d337%22%2C%22ue%22:%22699edff00000000028008ccc%22%2C%22uc%22:25}",
"acw_tc": "0a0d096b17728479400813507e65716b1f67026c1556a667d2cbd8eef79b3a",
"xsecappid": "ugc",
"loadts": "1772847946657",
"websectiga": "9730ffafd96f2d09dc024760e253af6ab1feb0002827740b95a255ddf6847fc8",
"sec_poison_id": "e52f4379-6e82-42d0-8133-d806bcc4d280"
}
url = 'https://creator.xiaohongshu.com/api/media/v1/upload/creator/permit?biz_name=spectrum&scene=image&file_count=1&version=1&source=web'
response = requests.get(url, headers=get_headers(cookie=cookies,url=url), cookies=cookies)
print(response.text)
print(response)

1312
xhs/js/mnsv2.js
File diff suppressed because it is too large
View File

11
xhs/js/t.js

@ -0,0 +1,11 @@
key1 ='kkk'
key2 = {'11':2}
if (key2 != undefined) {
if (typeof key2 == 'object'){
key2 = JSON.stringify(key2)
}
key1 += key2
}
console.log(key1)

143
xhs/js/补环境/huanjing.js

@ -0,0 +1,143 @@
window = global;
delete global;
location = {};
navigator = {
onLine: true,
pdfViewerEnabled: true,
platform: "Win32",
plugins: [],
presentation: {defaultRequest: null, receiver: null},
product: "Gecko",
productSub: "20030107",
scheduling: {},
serial: {onconnect: null, ondisconnect: null},
serviceWorker: {controller: null, ready: Promise, oncontrollerchange: null, onmessage: null, onmessageerror: null},
storage: {},
usb: {onconnect: null, ondisconnect: null},
userActivation: {hasBeenActive: true, isActive: false},
userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 SLBrowser/9.0.0.10191 SLBChan/25",
userAgentData: {mobile: false, platform: 'Windows'},
vendor: "Google Inc.",
vendorSub: "",
virtualKeyboard: {},
wakeLock: {},
webdriver: false,
deviceMemory: 8,
cookieEnabled: true,
language: "zh-CN",
languages: ['zh-CN', 'zh'],
href:"",
appCodeName: "Mozilla",
appName: "Netscape",
appVersion: '5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 SLBrowser/9.0.0.10191 SLBChan/25'
};
screen = {
availHeight: 834,
availLeft: 0,
availTop: 0,
availWidth: 1536,
colorDepth: 24,
height: 864,
isExtended: false,
onchange: null,
orientation: Symbol({angle: 0, type: 'landscape-primary', onchange: null}),
pixelDepth: 24,
width: 1536
};
document = {};
document.addEventListener = function (a){
console.log('---------------',a)
}
window.addEventListener = function (a){
console.log('---------------',a)
}
document.documentElement ={}
document.documentElement.getAttribute = function (a){
console.log('document.documentElement.getAttribute---------------',a)
}
window.document= document
better = {};
localStorage = {
};
Object.defineProperties(window, {
[Symbol.toStringTag]: {
value: "Window",
configurable: true
}
});
Object.defineProperties(navigator, {
[Symbol.toStringTag]: {
value: "Navigator",
configurable: true
}
});
Object.defineProperties(location, {
[Symbol.toStringTag]: {
value: "Location",
configurable: true
}
});
self = window;
document.createElement = function createElement(a) {
if (a == 'span') {
return {
'classList': {
'add': function () {
}
}
}
}
console.log('createElement-->:' + a)
};
document.documentElement = function documentElement(a) {
console.log('documentElement-->:' + a)
};
document.createEvent = function createEvent(a) {
console.log('documentElement-->:' + a)
};
document.all = {};
function requestAnimationFrame() {
}
window.requestAnimationFrame = requestAnimationFrame;
localStorage.getItem = function (a) {
console.log('getItem-->:' + a)
return localStorage[a]
}
function History() {}
History.prototype = watch({
toString: function toString() { return '[object History]'; },
}, "History");
History.prototype.constructor = History;
window.History = History;
window.history = watch(new History(), "window.history");
XMLHttpRequest = function (){}
globalThis = window;
var {proxies} = require('./proxies.js')
document = proxies.proxy(document, "document");
navigator = proxies.proxy(navigator, "navigator");
location = proxies.proxy(location, "location");
localStorage = proxies.proxy(localStorage, "localStorage");
screen = proxies.proxy(screen, "screen");
window = proxies.proxy(window, "window");
globalThis = proxies.proxy(globalThis, "globalThis");

972
xhs/js/补环境/mnsv2.js
File diff suppressed because it is too large
View File

196
xhs/js/补环境/proxies.js

@ -0,0 +1,196 @@
var proxies = {};
proxies.config = {};
proxies.config.start = true; // 是否启动拦截
proxies.config.get = true; // 是否拦截获取
proxies.config.set = true; // 是否拦截设置
proxies.config.apply = false; // 是否拦截函数执行
proxies.config.getOwnPropertyDescriptor = false; // 是否拦截获取自己的属性描述符
proxies.config.defineProperty = false; // 是否拦截定义属性
proxies.config.construct = false;
proxies.config.deleteProperty = false;
proxies.config.has = false;
proxies.config.ownKeys = false;
proxies.config.getPrototypeOf = false;
proxies.config.setPrototypeOf = false;
proxies.config.preventExtensions = false;
proxies.config.isExtensible = false;
proxies.config.index = 0
proxies.get_type = function (data) {
return Object.prototype.toString.call(data);
};
proxies.proxy = function proxy(obj, objName) {
//obj:原始对象
//objName:原始对象的名字
if (!proxies.config.start) {
console.log('代理已关闭');
return obj
}
let handler = {
get: function (target, prop, receiver) {//三个参数
//target: 原始对象 这里是user
//属性:属性 只有string和symbol两个类型
//receiver:代理后的对象 这里的proxyUser就是被代理后的对象
let result;
try {//防止出错
result = Reflect.get(target, prop, receiver);//和target[prop]是一样的 反射 执行原始操作
let type = proxies.get_type(result);
if (result instanceof Object) {
console.log(`${proxies.config.index}, 获取:[${objName}] -> 属性:[${prop.toString()}],type:[${type}]}`);
//递归调用
// result = proxies.proxy(result, `${objName}.${prop.toString()}`);//如果prop是Symbol类型${prop}会报错,这里toString是为了防止报错
} else if (typeof result === 'symbol') {
console.log(`${proxies.config.index}, 获取:[${objName}] -> 属性:[${prop.toString()}],结果:[${result.toString()}]}`);
} else {
console.log(`${proxies.config.index}, 获取:[${objName}] -> 属性:[${prop.toString()}],结果:[${result}]}`);// 这里使用${JSON.stringify(result)}输出可能会报错,如果result存在循环引用的话。
}
//throw new Error('测试error');
} catch (e) {
console.log(`${proxies.config.index}, 获取:[${objName}] -> 属性:[${prop.toString()}],error:[${e.message}]}`);
}
proxies.config.index += 1;
return result;
},
set: function (target, prop, value, receiver) {
let result;
try {
result = Reflect.set(target, prop, value, receiver);
let type = proxies.get_type(value);
if (value instanceof Object) {
console.log(`设置:[${objName}] -> 属性:[${prop.toString()}],type:[${type}]}`);
} else if (typeof value === 'symbol') {
console.log(`设置:[${objName}] -> 属性:[${prop.toString()}],value:[${value.toString()}]}`);
} else {
console.log(`设置:[${objName}] -> 属性:[${prop.toString()}],value:[${value}]}`);
}
} catch (e) {
console.log(`设置:[${objName}] -> 属性:[${prop.toString()}],error:[${e.message}]}`);
}
proxies.config.index += 1;
return result;
},
getOwnPropertyDescriptor: function (target, prop) {
let result;//结果两种 undefined和描述符对象
try {
result = Reflect.getOwnPropertyDescriptor(target, prop);
let type = proxies.get_type(result);
console.log(`getOwnPropertyDescriptor|obj:[${objName}] -> 属性:[${prop.toString()}],type:[${type}]}`);
//这里有需要再拦截,拦截的话会输出大量日志信息
//if(typeof result !== 'undefined'){
// result = ldvm.toolsFunc.proxy(result,`${objName}.${prop.toString()}.PropertyDescriptor`);
//}
} catch (e) {
console.log(`getOwnPropertyDescriptor|obj:[${objName}] -> 属性:[${prop.toString()}],error:[${e.message}]}`);
}
proxies.config.index += 1;
return result;
},
defineProperty: function (target, prop, descriptor) {
let result;
try {
result = Reflect.defineProperty(target, prop, descriptor);
console.log(`defineProperty|obj:[${objName}] -> 属性:[${prop.toString()}]}`);
} catch (e) {
console.log(`defineProperty|obj:[${objName}] -> 属性:[${prop.toString()}],error:[${e.message}]}`);
}
proxies.config.index += 1;
return result;
},
apply: function (target, thisArg, argumentsList) {
//target:函数对象
//thisArg:调用函数的this指针
//argumentsList:数组,函数的入参组长的一个列表
let result;
try {
result = Reflect.apply(target, thisArg, argumentsList);
let type = proxies.get_type(result);
if (result instanceof Object) {
console.log(`apply|function:[${objName}],type:[${result}]}`);
//一般不对函数返回的对象进行拦截,主要还是关注get函数拦截,针对浏览器接口,document,window这些
//特殊情况,可以对函数返回对象进行拦截
} else if (typeof result === 'symbol') {
console.log(`apply|function:[${objName}],result:[${result.toString()}]}`);
} else {
console.log(`apply|function:[${objName}],result:[${result}]}`);
}
} catch (e) {
console.log(`apply|function:[${objName}],error:[${e.message}]}`);
}
proxies.config.index += 1;
return result;
},
construct: function (target, argArray, newTarget) {
//target:函数对象
//argArray:调用函数的this指针
//newTarget:代理对象
let result;
try {
result = Reflect.construct(target, argArray, newTarget);
let type = proxies.get_type(result);
console.log(`construct|function:[${objName}],type:[${type}]}`);
} catch (e) {
console.log(`construct|function:[${objName}],error:[${e.message}]}`);
}
proxies.config.index += 1;
return result;
},
deleteProperty: function (target, propKey) {
let result = Reflect.deleteProperty(target, propKey);
console.log(`deleteProperty|obj:[${objName}] -> 属性:[${propKey.toString()}],result:[${result}]}`);
proxies.config.index += 1;
return result;
},
has: function (target, propKey) {//in 操作符
let result = Reflect.has(target, propKey);
console.log(`has|obj:[${objName}] -> 属性:[${propKey.toString()}],result:[${result}]}`);
proxies.config.index += 1;
return result;
},
ownKeys: function (target) {//
let result = Reflect.ownKeys(target);
console.log(`ownKeys|obj:[${objName}]}`);
proxies.config.index += 1;
return result;
},
getPrototypeOf: function (target) {//
let result = Reflect.getPrototypeOf(target);
console.log(`getPrototypeOf|obj:[${objName}]}`);
proxies.config.index += 1;
return result;
},
setPrototypeOf: function (target, proto) {//
let result = Reflect.setPrototypeOf(target, proto);
console.log(`setPrototypeOf|obj:[${objName}]}`);
proxies.config.index += 1;
return result;
},
preventExtensions: function (target) {//
let result = Reflect.preventExtensions(target);
console.log(`preventExtensions|obj:[${objName}]}`);
proxies.config.index += 1;
return result;
},
isExtensible: function (target, proto) {//
let result = Reflect.isExtensible(target);
console.log(`isExtensible|obj:[${objName}]}`);
proxies.config.index += 1;
return result;
}
};
let config_keys = Object.keys(handler);
for (let i = 0; i < config_keys.length; i++) {
if (proxies.config[config_keys[i]] !== true) {
// console.log('不拦截:' + config_keys[i])
delete handler[config_keys[i]]
} else {
// console.log('开始拦截:' + config_keys[i])
}
}
return new Proxy(obj, handler);
}
module.exports.proxies = proxies;

3588
xhs/js/补环境/qtr.js
File diff suppressed because it is too large
View File

4
xhs/js/补环境/run.js

@ -0,0 +1,4 @@
require('./huanjing.js')
require('./ttt.js')
console.log(window.mnsv2('url', undefined))

1504
xhs/js/补环境/ttt.js
File diff suppressed because it is too large
View File

1282
xhs/js/补环境/webpack.js
File diff suppressed because it is too large
View File

0
xhs/js/补环境/x9.js

103
xhs/main.py

@ -0,0 +1,103 @@
import time
from DrissionPage import Chromium, ChromiumOptions
class Xhs:
def __init__(self, cookies, target='video'):
cookies['domain'] = '.xiaohongshu.com'
self.cookies = cookies
self.url = f'https://creator.xiaohongshu.com/publish/publish?source=official&from=tab_switch&target={target}'
self.tab = self.page()
def init_co(self):
co = ChromiumOptions()
# 设置不加载图片、静音
co.incognito(True)
co.set_argument('--start-maximized')
co.set_pref(arg='profile.default_content_settings.popups', value='0')
# 隐藏是否保存密码的提示
co.set_pref('credentials_enable_service', False)
co.new_env()
return co
def upload_data(self, path):
ele = self.tab('@class=upload-wrapper')
ele.click.to_upload(path)
def page(self):
co = self.init_co()
tab = Chromium(co).latest_tab
tab.set.auto_handle_alert()
tab.set.cookies(cookies=self.cookies)
tab.get(self.url)
return tab
def input_title_connect(self, title, connect):
self.tab.ele('.d-text').input(title)
self.tab.ele('.tiptap ProseMirror').input(connect)
def send_data(self):
for i in range(10):
try:
html = self.tab.ele('.publish-page-publish-btn', timeout=3).html
if 'disabled=""' in html:
print('视频上传中等待')
time.sleep(2)
continue
else:
break
except Exception as e:
print(e)
self.tab.listen.start('/web_api/sns/v2/note')
for i in range(5):
try:
self.tab.ele('@text()=发布').click()
res = self.tab.listen.wait(timeout=3)
body = res.response.body
return body
except Exception as e:
print(e)
return False
def run(self, path=r'D:\2026-3\image\1.mp4'):
self.upload_data(path)
self.input_title_connect(title='我是标题', connect='我是内容')
body = self.send_data()
print(body)
self.tab.close()
if body['success'] is False:
return False
else:
return True
if __name__ == '__main__':
cookies = {
"a1": "197d0c0225d2ahcjv2md8l8lqat171mtu7y0pm97m50000115968",
"webId": "f2675311fd5ef2666e15073ef7876bb9",
"gid": "yjWf8S8JKJ7qyjWf8S8JJW6j2fJ0xSVhJ6fYvW61Y1A09828yWy69U888yy2jKY8YY0Yjf0i",
"x-user-id-ark.xiaohongshu.com": "6861bde9000000001e01790f",
"customerClientId": "706990196683713",
"x-user-id-fuwu.xiaohongshu.com": "6861bde9000000001e01790f",
"abRequestId": "f2675311fd5ef2666e15073ef7876bb9",
"web_session": "040069769f151fb684b60b65903b4b342673dc",
"id_token": "VjEAAApbUkDez1irEIDK8Xskk9WfmyF6jSocgzGzSSzuhxM1cdthEiup4YdxvB5E6aGLqvdW7DvcwGDBYIbfs0G2mejs1Wf5kYkdDCpD2bFo46Gu3EprnI8se/nm/lE80TPlBClU",
"customer-sso-sid": "68c517612540944882532354dbfxgoivhkkgdhc5",
"x-user-id-creator.xiaohongshu.com": "5a0457e4db2e6045e3f6d4e0",
"access-token-creator.xiaohongshu.com": "customer.creator.AT-68c517612540944882532355njwip1rjvzxfmmyi",
"galaxy_creator_session_id": "hMLkZfiS1vCMl6Ls1unn7AdCJN1EQuNkVHCZ",
"galaxy.creator.beaker.session.id": "1772432808364005045757",
"webBuild": "5.13.1",
"acw_tc": "0a0d0eb817726254956234444e57e6308e2dcf480967a5328f30b6f11f5399",
"xsecappid": "ugc",
"loadts": "1772625495974",
"unread": "{%22ub%22:%226982be1e0000000022023e65%22%2C%22ue%22:%226985d2c3000000000a02a602%22%2C%22uc%22:24}",
"websectiga": "16f444b9ff5e3d7e258b5f7674489196303a0b160e16647c6c2b4dcb609f4134",
"sec_poison_id": "1813469f-a50c-4fde-926e-fd85803ad45b"
}
# Xhs(cookies=cookies,target='video').run()
Xhs(cookies=cookies, target='image').run('1.png')

96
xhs/sing.py

@ -0,0 +1,96 @@
import hashlib
import hmac
from urllib.parse import quote
def sha1_hex(data: str) -> str:
return hashlib.sha1(data.encode("utf-8")).hexdigest()
def hmac_sha1_hex(key: bytes, msg: str) -> str:
return hmac.new(key, msg.encode("utf-8"), hashlib.sha1).hexdigest()
def canonical_kv(data: dict):
"""
JS:
D.obj2str(obj, true)
"""
items = []
for k in sorted(data.keys()):
key = quote(str(k).lower(), safe='')
val = quote(str(data[k]), safe='')
items.append(f"{key}={val}")
return "&".join(items)
def canonical_key_list(data: dict):
"""
JS:
y(obj, true).join(";").toLowerCase()
"""
return ";".join(sorted([k.lower() for k in data.keys()]))
def get_auth(params: dict):
secret_id = params.get("SecretId")
secret_key = params.get("SecretKey")
method = (params.get("Method") or params.get("method") or "get").lower()
query = params.get("Query") or {}
headers = params.get("Headers") or {}
pathname = params.get("Pathname") or ""
use_raw_key = params.get("UseRawKey", False)
key_time = params.get("KeyTime")
if not secret_id:
raise ValueError("missing param SecretId")
if not secret_key:
raise ValueError("missing param SecretKey")
# ===== 处理 Path =====
if not use_raw_key:
if not pathname.startswith("/"):
pathname = "/" + pathname
# ===== Canonical 处理 =====
header_list = canonical_key_list(headers)
param_list = canonical_key_list(query)
header_str = canonical_kv(headers)
param_str = canonical_kv(query)
# ===== HttpString =====
http_string = "\n".join([
method,
pathname,
param_str,
header_str,
""
])
http_sha1 = sha1_hex(http_string)
# ===== StringToSign =====
string_to_sign = "\n".join([
"sha1",
key_time,
http_sha1,
""
])
# ===== 计算签名 =====
sign_key = hmac_sha1_hex(secret_key.encode(), key_time)
signature = hmac_sha1_hex(sign_key.encode(), string_to_sign)
# ===== 拼接 Authorization =====
auth = "&".join([
"q-sign-algorithm=sha1",
f"q-ak={secret_id}",
f"q-sign-time={key_time}",
f"q-key-time={key_time}",
f"q-header-list={header_list}",
f"q-url-param-list={param_list}",
f"q-signature={signature}"
])
return auth

51
xhs/t.py

@ -0,0 +1,51 @@
import requests
from image_up import get_headers
headers = {
"accept": "application/json, text/plain, */*",
"accept-language": "zh-CN,zh;q=0.9",
"authorization;": "",
"cache-control": "no-cache",
"origin": "https://creator.xiaohongshu.com",
"pragma": "no-cache",
"priority": "u=1, i",
"referer": "https://creator.xiaohongshu.com/",
"sec-ch-ua": "\"Chromium\";v=\"9\", \"Not?A_Brand\";v=\"8\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"Windows\"",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-site",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 SLBrowser/9.0.6.8151 SLBChan/10 SLBVPV/64-bit",
"x-s": "XYS_2UQhPsHCH0c1PjhhHjIj2erjwjQM89PjNsQhPjHCHS4kJfz647PjNsQhPUHCHfM1qAZlPebKPbYxwrk9y0+72nbOJf4Q/BYep9rMcfLALo4Q4DFEcdSx8Sbk4/8Tafks+A+kJrWA+bcMpBRxaoYeyFR/z/PhJF+fJeSH4b434FR7/pQE/7q74LF6G7GlJgmr49+GN9k9y74MJ94PJBkfL78j4oz3cFih/7pfG/8/pbDAN7pVL9c6af8bG9k04BEkyA4TGA+C/ezIJB4C+LMhqeStLnIFLsHVHdWFH0ijHdF=",
"x-s-common": "2UQAPsHC+aIjqArjwjHjNsQhPsHCH0rjNsQhPaHCH0c1PjhhHjIj2eHjwjQgynEDJ74AHjIj2ePjwjQM89PjNsQh+sHCH0Z1P/rhN0ZjNsQh+aHCH0rEG9P9G/PMG9cUGn8DGAzDG/SM4gcMq/cUqArFwBRiqApA2opC8oQV+/ZIPeZ7PAZAweDjNsQh+jHCHjHVHdW7H0ijHjIj2eWjwjQQPAYUaBzdq9k6qB4Q4fpA8b878FSet9RQzLlTcSiM8/+n4MYP8F8LagY/P9Ql4FpUzfpS2BcI8nT1GFbC/L88JdbFyrSiafp/JDMra7pFLDDAa7+8J7QgabmFz7Qjp0mcwp4fanD68p40+fp8qgzELLbILrDA+9p3JpHlLLlz+LSk+d+DJfpSL98lnLYl49IUqgcMc0mrcDShtMmozBD6q7pFyFSh8o+h4g4U+obFyLSi4nbQz/+SPFlnPrDApSzQcA4SPopFJeQmzBMA/o8Szb+NqM+c4ApQzg8Ayp8FaDRl4AYs4g4fLomD8pzBpFRQ2ezLanSM+Skc47Qc4gcMag8VGLlj87PAqgzhagYSqAbn4FYQy7pTanTQ2npx87+8NM4L89L78p+l4BL6ze4AzB+IygmS8Bp8qDzFaLP98Lzn4AQQzLEAL7bFJBEVL7pwyS8Fag868nTl4e+0n04ApfuF8FSbL7SQyrplLLQl4LShyBEl20YdanTQ8fRl49TQcMkgzAqAq9zV/9pnLoqAag8m8/mf89pDPBloanDMqA+QGFFU4gzmanSNq9SD4fp3nDESpbmF+BEm/9pgLo4bag88Gnbm+np/pd4GqeStqFzc47QQPAzUagYb+LlM474Yqgq3qfp3ybkm/fLl/LESPbm7wLSe/d+n/BRSL9QQzDS3J7+/q04ApfEByLS3N7+npd4Hag8VJjRc4r+0Lo4danYtqFzl4MbQzLbAygb7JrSiN9prqgzm/dp7LBMn4FzQ2BMhag8zqbmDapQt/o8SP7bFyrSbzBbQyAmSngp7Lpkjzgb1PemAyfpHLFSbnLTcpd4zq7pFGLS3afpnLo4raM4dq9T8N9L9GDpEaLpt8nTDN7+3qgzAJSm7qLSeafp/Lo4kanWM8p8maLlQ40pSnnu68/mc4b+QcFTA+Sm7p0z6JgbQyrYSaL+d8p8PJ9pL878SnnH98/bl4M8QyezbaL+UzfEl4F+QPMZlanT68gYQ2d8EqfzSyMm7LrShG9Vhpd4oGfu78nDI+g+hpdzradbFprSkzdzQ4SPM4opF8fpl4M4Qy9RAygPI8LzM4Amt4gz8ag88/pbn4BRQy7H7cS4y2rDA8oP9G0+AyLMw8p+M49YUpdc7agYy2rS3P7+r4gzSagG98pz6zgbQybbwaBpIyrSiLfYQye4S8Sm7cdbM4rpSLoz1anSM2LSe/d+DnnpSzbm720Y1anEQyrlUqbmFPLYc4b+QynYTanTLwLDALFYQcFRS8rQdq981qBpspd4eanYB2D4n4Fbz4g4YaLP68Lz6qjRQPFGh2LzD8gYM4B+OpdznLppPPpm+nSbQPMz0wb87pFShPo+DPbShanTjwnRc4ASQypS0tM8Fyfpl4ebQzpZEagGhpFSi2SmUpd4DanSU/rSb+gPA4g4GJURQpDSbpBRQP9RAyDH6qMzc4UTQ2bzaanSMpnMVLdYQc9WRHjIj2eDjwjFl+0LUw/qh+/PVHdWlPsHCPsIj2erlH0ijJfRUJnbVHdF=",
"x-t": "1772869510872"
}
cookies = {
"gid": "yjWf8S8JKJ7qyjWf8S8JJW6j2fJ0xSVhJ6fYvW61Y1A09828yWy69U888yy2jKY8YY0Yjf0i",
"x-user-id-ark.xiaohongshu.com": "6861bde9000000001e01790f",
"customerClientId": "706990196683713",
"x-user-id-fuwu.xiaohongshu.com": "6861bde9000000001e01790f",
"abRequestId": "f2675311fd5ef2666e15073ef7876bb9",
"web_session": "040069769f151fb684b60b65903b4b342673dc",
"id_token": "VjEAAApbUkDez1irEIDK8Xskk9WfmyF6jSocgzGzSSzuhxM1cdthEiup4YdxvB5E6aGLqvdW7DvcwGDBYIbfs0G2mejs1Wf5kYkdDCpD2bFo46Gu3EprnI8se/nm/lE80TPlBClU",
"customer-sso-sid": "68c517612540944882532354dbfxgoivhkkgdhc5",
"x-user-id-creator.xiaohongshu.com": "5a0457e4db2e6045e3f6d4e0",
"access-token-creator.xiaohongshu.com": "customer.creator.AT-68c517612540944882532355njwip1rjvzxfmmyi",
"galaxy_creator_session_id": "hMLkZfiS1vCMl6Ls1unn7AdCJN1EQuNkVHCZ",
"galaxy.creator.beaker.session.id": "1772432808364005045757",
"webBuild": "5.14.0",
"a1": "19cc6a35cd2afdc4da9uut5q42s148ohs5sxuzdrl50000730389",
"webId": "6c1e44a576d6408f5b88236ee713beaa",
"unread": "{%22ub%22:%22699ecd8e000000001a02055f%22%2C%22ue%22:%22699d5a5a0000000015021bf9%22%2C%22uc%22:25}",
"xsecappid": "ugc",
"websectiga": "f47eda31ec99545da40c2f731f0630efd2b0959e1dd10d5fedac3dce0bd1e04d",
"sec_poison_id": "b2a0eca7-0b0a-4284-8694-eb8c580fc34e",
"loadts": "1772869490393"
}
url = "https://www.xiaohongshu.com/web_api/sns/v5/creator/file/encryption?file_id=%2Fspectrum%2LjVrytyODKOm9pSicNoadubSne2IXh40TbEQyw8IO36aIAc&type=image&ts=1772869510861&sign=0f37b5816f1a65c43087554236326cf3"
response = requests.get(url, headers=get_headers(cookie=cookies,url=url), cookies=cookies)
print(response.text)
print(response)
Loading…
Cancel
Save