要使用Stack Overflow上的r -tag 庆祝第20,000个问题,请帮助我从Wikipedia页面中提取R发布日期.
我的尝试:
library(XML)
x <- readHTMLTable("http://en.wikipedia.org/wiki/R_(programming_language)")
Run Code Online (Sandbox Code Playgroud)
这不起作用,因为该表实际上是一个列表,而不是HTML表.
library(httr)
x <- GET("http://en.wikipedia.org/wiki/R_(programming_language)")
text <- content(x, "parsed")
Run Code Online (Sandbox Code Playgroud)
这会提取文本,但我xpath生锈了,所以我无法提取相关的发布日期.
我怎样才能做到这一点?
PS.维基百科页面是我能找到的唯一来源,但如果有的话,请随意使用规范来源发布解决方案.
我想用它Intl.DateTimeFormat来格式化Date,并在示例中说明
// when requesting a language that may not be supported, such as
// Balinese, include a fallback language, in this case Indonesian
Run Code Online (Sandbox Code Playgroud)
很好,所以我希望我的后备是ISO 8601,如果语言不存在的话
// i.e. the same as/similar to
new Date().toISOString(); // "2014-07-31T02:42:06.702Z"
Run Code Online (Sandbox Code Playgroud)
然而
// Intl.DateTimeFormat([locales [, options]])
var o = {};
o.year = o.month = o.day = o.hour = o.minute = o.second = 'numeric';
new Intl.DateTimeFormat(['foo', 'iso8601'], o);
// RangeError: Invalid language tag: iso8601
Run Code Online (Sandbox Code Playgroud)
这似乎是因为iso8601不是其中的一部分
locales带有BCP 47 …
我有2个窗户home.html和result.html.
在home.html我有一个<textarea> #txtinput和<button> #btn.
在result.html我有另一个<textarea> #txtresult.
在home.html,如果我输入一个值#txtinput并单击#btn,我想开result.html并传递价值的#txtinput到#txtresult.
我从另一篇文章中尝试了下面的代码,它在新窗口的主体中显示了值,但是不会在我的元素中显示它
var myWindow = window.open();
myWindow.document.body.innerHTML = document.getElementById("txtinput").value;
Run Code Online (Sandbox Code Playgroud)
它是以某种方式以简单的方式实现的吗?我对JavaScript比较陌生,我的课程现在正在进行中,我很想知道如何做到这一点.任何详细的帮助将非常感谢!
如何在不创建的情况下创建一个独立于(如此修改,例如不起作用)的新Window对象?myWindowwindowmyWindow.Array.prototypewindow.Array.prototype<iframe>
目前我正在做如下的事情
function newWindow(){
var myFrame = document.createElement('iframe'), myWindow = undefined;
myFrame.style.display = 'none';
myFrame.src = 'javascript:undefined;';
document.body.appendChild(myFrame);
myWindow = myFrame.contentWindow;
document.body.removeChild(myFrame);
return myWindow;
}
Run Code Online (Sandbox Code Playgroud)
最后,我想制作我自己的核心对象类型副本并对其进行原型化.
我正在考虑使用本机方法创建包含默认值的数组的方法,最后结束
function pushMap(length, fill){
var a = [], b = [];
a.length = length;
b.push.apply(b,a);
return b.map(function(){return fill;});
}
Run Code Online (Sandbox Code Playgroud)
期待它是2或3比while循环慢倍,作为本机方法必须循环两次而while循环一次,所以我相比它jsperf针对
function whileLengthNew(len, val) {
var rv = new Array(len);
while (--len >= 0) {
rv[len] = val;
}
return rv;
}
Run Code Online (Sandbox Code Playgroud)
它实际上慢了18到27倍(在Ubuntu上使用Google Chrome进行测试,欢迎使用浏览器/操作系统).
发生了什么导致如此巨大的差异?
如果我想在打开.py文件时将64位Python 3.3作为默认值,那么安装32位和64位版本的Python 2.7和Python 3.3的最佳方法/顺序是什么?
我已经安装了32位版本,默认设置为Python 3.3.
如果它是好的,只是重命名我的当前安装版本的目录,将python27.dll并使用它(或程序python33.dll)继续工作?这个库由python安装程序安装到%WINDIR%\ System32和/或%WINDIR%\ SysWoW64.
谢谢你的回答,这就是我所做的:
C:\Python\27_32\C:\Python\27\C:\Python\33_32\C:\Python\33\var p = "null"
var q = null;
(p == q) //false. as Expected.
p.replace(null, "replaced") // outputs replaced. Not expected.
p.replace("null", "replaced") //outputs replaced. Expected.
q.replace(null, "replaced") // error. Expected.
q.replace("null", "replaced") //error. Expected.
Run Code Online (Sandbox Code Playgroud)
为什么?是否更换之间无法区分"null"和null?
我问是因为我遇到了angularjs中的错误:
replace((pctEncodeSpaces ? null : /%20/g), '+');
Run Code Online (Sandbox Code Playgroud)
例如,如果某人的用户名是"null"且被用作url,则在任何$http呼叫中它将被替换为“ +” 。例如GET /user/null。
并不是说这种情况会经常发生,而是我很好奇为什么替换对待null和对待"null"同一件事。null在替换之前,replace会在其上执行.tostring 吗?这只是Java语言的怪癖吗?
我在IE和Chrome的实施中都对此进行了验证replace。
说我有一个参考的html文件的斑点 b和我创建一个URL它,url = URL.createObjectURL(b);.
这给了我一些看起来像的东西 blob:http%3A//example.com/a0440b61-4850-4568-b6d1-329bae4a3276
然后我尝试<iframe>使用GET参数打开?foo=bar它,但它不起作用.我怎样才能传递参数?
var html ='<html><head><title>Foo</title></head><body><script>document.body.textContent = window.location.search<\/script></body></html>',
b = new Blob([html], {type: 'text/html'}),
url = URL.createObjectURL(b),
ifrm = document.createElement('iframe');
ifrm.src = url + '?foo=bar';
document.body.appendChild(ifrm);
// expect to see ?foo=bar in <iframe>
Run Code Online (Sandbox Code Playgroud)
我正在使用setAttribue如下。它仅在第一次工作,之后显示变化的值,alert但不显示document.getElementById("to").setAttribute("value", selValue);
document.getElementById("listcontact").onchange = function () {
var selIndex = document.getElementById("listcontact").selectedIndex;
var selValue = document.getElementById("listcontact").options[selIndex].innerHTML;
var contactVal = selValue.split(';');
var phone = contactVal[2];
alert(phone);
document.getElementById("to").setAttribute("value", selValue);
selIndex = "";
selValue = "";
phone = "";
selValue = "";
};
Run Code Online (Sandbox Code Playgroud)
为什么这不能按我预期的那样工作,我该如何解决?
javascript ×8
html ×2
blob ×1
install ×1
localization ×1
performance ×1
python ×1
r ×1
window.open ×1
windows-7 ×1