我正在使用ruby版本1.9.3,我喜欢从下面的视频网址获取主机名,
我试过代码
require 'uri'
url = "https://ferrari-view.4me.it/view-share/playerp/?plContext=http://ferrari-%201363948628-stream.4mecloud.it/live/ferrari/ngrp:livegenita/manifest.f4m&cartellaConfig=http://ferrari-4me.weebo.it/static/player/config/&cartellaLingua=http://ferrari-4me.weebo.it/static/player/config/&poster=http://pusher.newvision.it:8080/resources/img1.jpg&urlSkin=http://ferrari-4me.weebo.it/static/player/swf/skin.swf?a=1363014732171&method=GET&target_url=http://ferrari-4me.weebo.it/static/player/swf/player.swf&userLanguage=IT&styleTextColor=#000000&autoPlay=true&bufferTime=2&isLive=true&highlightColor=#eb2323&gaTrackerList=UA-23603234-4"
puts URI.parse(url).host
Run Code Online (Sandbox Code Playgroud)
它抛出异常URI :: InvalidURIError:错误的URI(不是URI?):
我尝试使用编码URL然后解析如下
puts URI.parse(URI.parse(url)).host
Run Code Online (Sandbox Code Playgroud)
它抛出异常相同 URI::InvalidURIError: bad URI(is not URI?)
但上面的代码适用于以下URL.
url = http://www.youtube.com/v/GpQDa3PUAbU?version=3&autohide=1&autoplay=1
如何解决这个问题?任何建议请.谢谢
如何在.NET /foo/bar.txt中将绝对或相对URI路径(例如)转换为(分段)相应的相对文件系统路径(例如foo\bar.txt)?
我的程序不是ASP.NET应用程序.
我正在WCF 4.0中开发一些RESTful服务.我有一个方法如下:
[OperationContract]
[WebGet(UriTemplate = "Test?format=XML&records={records}", ResponseFormat=WebMessageFormat.Xml)]
public string TestXml(string records)
{
return "Hello XML";
}
Run Code Online (Sandbox Code Playgroud)
因此,如果我将浏览器导航到http:// localhost:8000/Service/Test?format = XML&records = 10,那么一切都可以正常运行.
但是,我希望能够导航到http:// localhost:8000/Service/Test?format = XML并且不使用URL的"&records = 10"部分.但是现在,我收到服务错误,因为URI与预期的URI模板不匹配.
那么如何为我的一些查询字符串参数实现默认值呢?我希望将"记录"默认为10,例如,如果该部分不在查询字符串中.
在Yii中,如何获取当前页面的URL.例如:
http://www.yoursite.com/your_yii_application/?lg=pl&id=15
Run Code Online (Sandbox Code Playgroud)
但不包括$GET_['lg'](没有手动解析字符串)?
我的意思是,我正在寻找类似于Yii::app()->requestUrl/ Chtml::link()方法的东西,用于返回URL减去一些$_GET变量.
编辑:当前解决方案:
unset $_GET['lg'];
echo Yii::app()->createUrl(
Yii::app()->controller->getId().'/'.Yii::app()->controller->getAction()->getId() ,
$_GET
);
Run Code Online (Sandbox Code Playgroud) 从中提取的好方法是什么filename.jpg:
url = 'http://www.example.com/foo/bar/filename.jpg?2384973948743'
Run Code Online (Sandbox Code Playgroud)
我正在使用Ruby 1.9.3.
我正在寻找使用System.UriBuilder更改给定System.Uri实例的方案的规范方法,而不需要糟糕的字符串操作和魔术常量.说我有
var uri = new Uri("http://localhost/hello")
Run Code Online (Sandbox Code Playgroud)
我需要将其更改为" https ".我的问题是在有限的UriBuilderctors和Uri.Port默认为80(我们应该将它改为443?硬编码?).代码必须遵守所有Uri属性,例如可能的基本身份验证凭据,查询字符串等.
我在4.4.2,尝试通过uri删除文件(图像).这是我的代码:
File file = new File(uri.getPath());
boolean deleted = file.delete();
if(!deleted){
boolean deleted2 = file.getCanonicalFile().delete();
if(!deleted2){
boolean deleted3 = getApplicationContext().deleteFile(file.getName());
}
}
Run Code Online (Sandbox Code Playgroud)
目前,这些删除功能都没有实际删除该文件.我的AndroidManifest.xml中也有这个:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
Run Code Online (Sandbox Code Playgroud) 我收到此错误消息:
java.net.URISyntaxException: Illegal character in query at index 31: http://finance.yahoo.com/q/h?s=^IXIC
Run Code Online (Sandbox Code Playgroud)
My_Url = http://finance.yahoo.com/q/h?s=^IXIC
当我将它复制到浏览器地址字段时,它显示正确的页面,它是有效的URL,但我不能解析它:new URI(My_Url)
我试过了My_Url=My_Url.replace("^","\\^"),但是
怎么办呢?
坦率
我目前有两项活动.一个用于从SD卡中提取图像,一个用于蓝牙连接.
我利用Bundle从活动1转移图像的Uri.
现在我希望做的就是该URI的蓝牙活动,它通过字节数组转换为传递状态我已经看到了一些例子,但我似乎无法让他们为我的代码工作!
Bundle goTobluetooth = getIntent().getExtras();
test = goTobluetooth.getString("ImageUri");
Run Code Online (Sandbox Code Playgroud)
是我必须把它拉过来,下一步会是什么?
非常感谢
可靠的人
我已多次向我解释所有URL都是URI,但并非所有URI都是URL.任何人都可以给出一个URI的例子,但不是URL吗?
uri ×10
url ×3
.net ×2
android ×2
c# ×2
java ×2
ruby ×2
bytearray ×1
current-page ×1
delete-file ×1
file ×1
frameworks ×1
path ×1
php ×1
query-string ×1
uritemplate ×1
wcf ×1
yii ×1