URI 提取在冒号处转义,有什么方法可以避免这种情况吗?
我有下面的函数,通常会输出一个 URL,例如 path.com/p/12345
。
有时,当推文之前包含冒号时,例如
RT:一些path.com/p/123
函数将返回的内容:
personName:
path.com/p/12345
我的功能:
$a = 10
def grabTweets()
tweet = Twitter.search("[pic] "+" path.com/p/", :rpp => $a, :result_type => "recent").map do |status|
tweet = "#{status.text}" #class = string
urls = URI::extract(tweet) #returns an array of strings
end
end
我的目标是找到 URL 之前带有冒号的任何推文,并将该结果从循环中删除,以便它不会返回到创建的数组。
I have the following function below that will normally spit out a URL such as path.com/p/12345
.
Sometimes, when a tweet contains a colon before the tweet such as
RT: Something path.com/p/123
the function will return:
personName:
path.com/p/12345
My function:
$a = 10
def grabTweets()
tweet = Twitter.search("[pic] "+" path.com/p/", :rpp => $a, :result_type => "recent").map do |status|
tweet = "#{status.text}" #class = string
urls = URI::extract(tweet) #returns an array of strings
end
end
My goal is to find any tweet with a colon before the URL and remove that result from the loop so that it is not returned to the array that is created.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你只能选择HTTP URL:
你的方法也可以清理很多,你有很多多余的局部变量:
我也想强烈反对你使用全局变量(
$a
) 。You can only select HTTP URLs:
Your method can also be cleaned up quite a bit, you have a lot of superfluous local variables:
I also want to strongly discourage your use of a global variable (
$a
).