从密码保护的网站读取R文本 [英] read text file into R from password protected website

查看:281
本文介绍了从密码保护的网站读取R文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个工作脚本(Windows 32位),它使用read.csv从受密码保护的网站成功读取txt文件。以下是非常简单的代码片段:

I had a working script (Windows 32 bit) that sucessfully read a txt file from a password protected web site onwith read.csv. Below is a snippet of the very simple code:

fname <- "http://www.frontierweather.com/degreedays/StatePopulationWeightedWeatherData_Since2010.txt"
dd2 <- read.csv(fname, sep=",", header=T)

然后我有一台新的电脑(Windows 64位),而read.csv是没有loger似乎能够超越网站认证。而不是阅读数据,它读入一个似乎与网站身份验证相关的乱码数据帧:

Then I got a new computer (Windows 64 bit) and the read.csv is no loger seems able to get beyond the websites authentication. Instead of reading in the data it reads in a garbled dataframe that seems to be related to the web sites authentication:

> head(dd2)
                   X..DOCTYPE.html.PUBLIC....W3C..DTD.XHTML.1.0.Transitional..EN
1                       http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
2                                      <html xmlns=http://www.w3.org/1999/xhtml>
3                                                                         <head>
4                                                    <title>Please login</title>
5                                            <link rel=stylesheet type=text/css 
6         href=http://www.frontierweather.com/amember/templates/css/reset.css />

成功,我尝试了几件事来尝试使其工作:

Uncessfully, I've tried several things to try to get it to work:


  1. 从旧机器转移的cookie

  2. 打开网站,当提示允许窗口保存用户名和密码时>
  3. 带有user:password @的前缀URL(fname)

  4. 在数据存储为受信任站点的网站中,

  5. 检查新计算机和旧计算机上的所有密码是否相同

  6. 验证旧机器和新机器是否运行相同的版本( Internet Explorer的版本9)

  1. Transfered cookies over from old machine
  2. opened website and when prompted allowed windows to save user name and password
  3. prefixed URL (in fname) with "user:password@"
  4. In interent explorer set website where data is stored as a "trusted site".
  5. Checked that all ackages are the same on the new computer and old computer
  6. Verified that both the old and new machine are running the same version (version 9) of Internet Explorer

任何帮助或方向将不胜感激。

Any assistance or direction would be greatly appreciated.

推荐答案

我想到了我的问题,既然我浪费了一整天的时间来解决这个问题,我想分享一下我的解决方案,希望不会对别人造成同样的恐慌造成我

I figured out my problem and since I wasted an entire day trying to solve this, I wanted to share my solution so hopefully it won’t cause the same consternation for others as it caused me.

首先,据我所知,这个问题与R或从32位机器切换到64位机器绝对无关。相反,它似乎源自Internet Explorer 7中引入的新的Internet Explorer新设置。

First, as far as I can tell, the problem has absolutely nothing to do with R or switching from a 32 to 64 bit machine. Instead it all seems to stem from a new setting in Internet Explore that was introduced beginning with Internet Explorer 7.

在Internet Explorer的选项中,启用保护模式(需要重新启动Internet Explorer),默认情况下打开(选中)。 Internet Explorer允许您更改以下每个安全区域的设置:Internet,本地Intra Net,受信任的站点和受限站点。

In Internet Explorer’s options there option to "Enable Protected Mode (requires restarting Internet Explorer)" that is turned on (checked) by default. Internet Explorer allows you to change the setting for each of the following security zones: Internet, Local Intra Net, Trusted Sites, and Restricted Sites.

添加我的数据被提供到受信任的站点列表中,我通过取消选中该框禁用启用保护模式。一旦进行了这个更改,并重新启动了Internet Explorer,那么read.csv(上图)就完美地运行了。

After adding the URL where my data was being sourced to the list of Trusted Sites, I turned off the Enable Protected Mode by unchecked the box. Once this change was made and Internet Explorer was restarted the read.csv (above) worked perfectly.

在做了一些进一步的研究后,我发现了以下内容:

After doing some further research I found the following:


保护模式有助于防止恶意软件在Internet Explorer 7中利用
漏洞,保护您的计算机免受
最常见的黑客攻击访问您的系统。
- 如何禁用Internet Explorer 7中的保护模式

大概通过启用保护模式(我的新电脑附带的默认设置);这是阻止R访问包含我的用户名和密码的cookie被馈送到R和/或返回到Internet Explorer以检索数据。

Presumably by having the Protected Mode enabled (a default setting that came with my new computer); it was preventing R from accessing the cookies which contained my username and password from being fed to R and/or back to Internet Explorer to retrieve the data.

这篇关于从密码保护的网站读取R文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆