Youtube 安全搜索 [英] Youtube Safe Search
问题描述
我不确定这个问题是否应该放在这里.
I am not sure if this question should go here.
我应该如何更改 youtube 首选项 cookie 以便始终开启安全模式?
How should i change the youtube preference cookie so that safety mode is always on?
PREF=f1=50000000&fms2=30000&fms1=30000&fv=10.3.183
这是首选 cookie,如果关闭安全搜索,fms2
将更改为 10000
.如果 fms2=10000
出现在 cookie 中,我使用正则表达式替换来替换文本.但这似乎不起作用.我如何更改 cookie 以便关闭安全模式会由于 cookie 替换而将其重新打开?
This is the pref cookie and fms2
changes to 10000
if safe search is turned off. I used regex replace to replace the text if fms2=10000
comes in the cookie. But this doesn't seem to work. How do I change the cookie so that turning off safety-mode will turn it back on due to the cookie replace?
推荐答案
第一:我真的不确定我是否正确理解了你的问题.对于从 fms2=10000
到 fms2=30000
的静态字符串替换,您不一定需要使用 Regex.正常"字符串替换也可以.但我想还有更多?您使用哪种语言?
First: I am really not sure if I understand your question correctly. For a static string replacement from fms2=10000
to fms2=30000
you should not necessarily need to use Regex. "Normal" string replacement would also do it. But I guess there is more? Which language do you use?
第二:关闭安全模式将由于 cookie 替换而将其重新打开"是什么意思?你想交换逻辑:关闭"实际上是打开",反之亦然?
Second: What do you mean by "that turning off safety-mode will turn it back on due to the cookie replace"? Do you want to swap the logic: "turn off" does actually a "turn on" and vice versa?
第三:您的数据中是否有一些您可能不知道的额外修改,例如 URL 编码?
Third: Is there some additional modification in your data like URL encoding that you are maybe not aware of?
更新:我对正则表达式的猜测是(PCRE 语法 - 我对 C++ 不太熟悉)
UPDATE: My guess for the regex is (PCRE syntax - I am not so familiar with C++)
/^(?=PREF\=)(.*?(?:PREF\=|&)fms2=).*?($|&.*)/
替换为
$130000$2
这将匹配
PREF=f1=50000000&fms2=10000&fms1=30000&fv=10.3.183
PREF=f1=50000000&fms2=&fms1=30000&fv=10.3.183
PREF=f1=50000000&fms1=30000&fv=10.3.183&fms2=123
PREF=fms2=123&f1=50000000&fms1=30000&fv=10.3.183
但这听起来不仅仅是一个正则表达式问题,不是吗?如果您遇到问题或需要对模式进行解释,请告诉我.
But it sounds like this is not only a regex problem, isn't it? Please let me know if you are facing problems or you need an explanation of the pattern.
这篇关于Youtube 安全搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!