Comments (4)
@Finb 十分感谢!我是用Python3
实现的,实现代码如下
import requests
import urllib
def encode_text(text):
return urllib.parse.quote(text.encode('utf-8'))
# 对中文文字编码
chinese_text = '2019年诺贝尔经济学奖'
url = 'https://wiki.mbalib.com/wiki/' + encode_text(chinese_text)
# 再对整个url编码
url = encode_text(url)
from bark.
你好
因为你这整个URL是当做url字段的参数,所以需要对整个URL进行编码(encodeURIComponent)
像这样
https%3a%2f%2fwiki.mbalib.com%2fwiki%2f2019%e5%b9%b4%e8%af%ba%e8%b4%9d%e5%b0%94%e7%bb%8f%e6%b5%8e%e5%ad%a6%e5%a5%96
然后将编码后的结果当成推送url的参数
from bark.
很感谢作者的及时回复,但我进行尝试后,发现依旧不行
from bark.
@wnma3mz 确实不行,忘了还有一步,问题出在URL中有中文
实际上url中是不能有中文的,中文会导致Swift初始化URL对象时出错
//现在还不是一个合法的url,因为url中有中文
var url:String = "https://wiki.mbalib.com/wiki/2019年诺贝尔经济学奖";
//将URL路径或参数部分的特殊字符或中文编码,使url合法。编码后url的值变为:
//https://wiki.mbalib.com/wiki/2019%E5%B9%B4%E8%AF%BA%E8%B4%9D%E5%B0%94%E7%BB%8F%E6%B5%8E%E5%AD%A6%E5%A5%96
url = url.encodeURI();
//将整个url编码,当做推送URL的参数部分
url = url.encodeURIComponent();
//最后的Url是
//https%3A%2F%2Fwiki.mbalib.com%2Fwiki%2F2019%25E5%25B9%25B4%25E8%25AF%25BA%25E8%25B4%259D%25E5%25B0%2594%25E7%25BB%258F%25E6%25B5%258E%25E5%25AD%25A6%25E5%25A5%2596
//把这个Url当做url的参数推送出去就可以了
建议所有url都经过 url.encodeURI().encodeURIComponent() 处理后,再当做推送链接的url参数值,基本就没问题了
encodeURI() 方法是对一个url进行编码,使url合法
encodeURIComponent()方法是对 一个字符串,整体都url编码
这里是js里的方法,不过其他语言都能找到对应实现
from bark.
Related Issues (20)
- 请问有安卓端的替代品吗?
- bark闪退
- bark能否实现定时推送的功能 HOT 1
- 作者您好,想咨询一下icon能否刷新. HOT 1
- 可以支持自动粘贴吗 HOT 2
- iv 中包含 \r\n 导致 Decryption Failed
- 一个功能更完善的Python包,支持所有参数
- 在IOS17.2.1上使用,通知无法亮屏 HOT 2
- 电报群邀请链接过期了 HOT 1
- 请问是否可以添加支持url scheme添加服务器
- iOS 17.3.1 cannot get device token
- 重置失败,没有获取到 DeviceToken HOT 1
- POST 请求参数问题 HOT 2
- ios增加自定义铃声设置 HOT 2
- 建议,能否增加定期自动清理
- 历史消息高亮未读消息
- device token变成了未知 HOT 1
- iOS 17.5.1 Decryption Failed HOT 4
- 消息图标不支持webp格式的吗?
- 有没有mac版本
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bark.