Spaces:
Sleeping
Sleeping
Create muid.py
Browse files
muid.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 导入requests库
|
| 2 |
+
import requests
|
| 3 |
+
|
| 4 |
+
# 定义一个函数,获取muid的值
|
| 5 |
+
def get_muid():
|
| 6 |
+
# 创建一个session对象
|
| 7 |
+
session = requests.Session()
|
| 8 |
+
# 设置请求头,模拟浏览器访问
|
| 9 |
+
headers = {
|
| 10 |
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36"
|
| 11 |
+
}
|
| 12 |
+
# 发送get请求,获取响应
|
| 13 |
+
response = session.get(
|
| 14 |
+
url="https://www.bing.com/?form=000047&ocid=msedgntp&cvid={str(uuid.uuid4()).replace('-','')}&ei=14",
|
| 15 |
+
headers=headers,
|
| 16 |
+
allow_redirects=True
|
| 17 |
+
)
|
| 18 |
+
# 获取响应中的cookies
|
| 19 |
+
cookies = response.cookies
|
| 20 |
+
# 返回muid的值,如果没有则返回None
|
| 21 |
+
return cookies.get("MUID", None)
|
| 22 |
+
|
| 23 |
+
# 调用函数,打印结果
|
| 24 |
+
muid = get_muid()
|
| 25 |
+
print(f"The value of muid is: {muid}")
|