- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试“屏幕抓取”一些数据我有一个请求如下(来自 fiddler )
POST http://fallenlondon.storynexus.com/Auth/EmailLogin HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Referer: http://fallenlondon.storynexus.com/signup
User-Agent: Mine
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Cache-Control: max-age=0
l:
Origin: http://fallenlondon.storynexus.com/
DNT: 1
Accept-Encoding: utf-8
Accept-Language: en-GB,en;q=0.8
Cookie: ASP.NET_SessionId=05xq3gndu4nczvy5wsah5qyw; __utma=100212060.1740063036.1431282067.1431282067.1431284767.2; __utmb=100212060.14.10.1431284767; __utmc=100212060; __utmz=100212060.1431282067.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
Host: fallenlondon.storynexus.com
Content-Length: 54
(内容是我的凭据)- 此 header 与我在浏览器中手动查看网页时跟踪的请求相匹配。
我使用 HttpWebRequest.GetResponse() 发送这个我收到回复
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: text/html; charset=utf-8
Date: Mon, 11 May 2015 20:54:15 GMT
Expires: -1
Pragma: no-cache
Server: Microsoft-IIS/8.0
X-AspNet-Version: 4.0.30319
X-AspNetMvc-Version: 4.0
X-Powered-By: ASP.NET
X-Server: Web1
Content-Length: 16900
Connection: keep-alive
这(再次)与我使用浏览器获得的结果相匹配。使用 fiddler,我可以看到 17k 的数据 (html),我尝试使用...阅读它
var stream = response.GetResponseStream();
if (stream == null) return null;
using (var reader = new StreamReader(stream, Encoding.UTF8))
{
var data = reader.ReadToEnd();
reader.Close();
return data;
}
我在“new StreamReader”行上遇到异常,指出“Stream is not readable”我的调试器显示流既不可读也不可写。这是我阅读的第二页(第一页是对主网址的简单请求以获取登录页面)。使用相同的代码可以正常工作。所有流和请求在使用后都已关闭。
Google 没有给我任何帮助,提示页面错误(不,状态为 200)或已经读取数据(不,代码直接在这里)我根本没有使用线程,所以这不是问题。我已经尝试更改编码(请求 gzip 给我一个较小的有效载荷,但我仍然无法读取它)我在 win7 x64 上使用 c#.net 4.5.2
有谁知道我做错了什么吗?
最佳答案
噢!由于代码中的“疏忽”,我试图读取流两次!现在一切正常
关于c# - 读取 HttpWebResponse 时获取 "Stream not readable",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30177798/
我尝试使用可读性模块,但出现以下错误。我怎样才能让用户获得“可读性”? /usr/local/opt/python/bin/python3.6:没有名为 readability.readability
Node 文档说(可读流的read事件): Once the internal buffer is drained, a readable event will fire again when mor
我必须在 APL 中编码。由于代码要维护很长时间,我想知道是否有一些论文/书籍包含启发式/技巧/示例来帮助设计干净可读的 APL 程序。 这与使用其他编程语言进行编码是一种不同的体验。例如,制作一个函
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be
boolean f(boolean A, boolean B, boolean C, boolean D, boolean E) { if (A) { k(); if (B)
关闭。这个问题是opinion-based .它目前不接受答案。 想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题. 6年前关闭。 Improve t
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 10年前关闭。 Improve this
如何编写易于被其他人阅读并且没有参与编写任何部分的代码? 最佳答案 确保其他人可以阅读您的代码的最佳方法是确保它清晰简洁。即, 对变量、函数和类使用自记录名称。 对复杂的算法进行注释,这样读者就不必花
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be
已结束。此问题正在寻求书籍、工具、软件库等的推荐。它不满足Stack Overflow guidelines 。目前不接受答案。 我们不允许提出寻求书籍、工具、软件库等推荐的问题。您可以编辑问题,以便
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 9 年前。 Improve
我有自定义 UITableView,我将背景颜色设置为白色。这适用于黑暗和明亮模式。但在暗模式下,披露指标很难看到。 我尝试使用 cell.tint 颜色修复此问题,但它不起作用。我该如何解决? 深色
我有一堆看起来像这样的字符: Комуникацион&
我正在通过learn you a haskell教程和 我一直在绊倒作者的一些例子 已经给。 例如,他重新实现了 zip 如下: zip' :: [a] -> [b] -> [(a,b)] zip'
假设您正在制作一个博客软件,并且想要显示一个条目获得的评论数量。你可以这样做: [Entry title] [Content........] [ Comments] 这可能会导致: [Entry
简单的问题(如果这太基于意见,我们深表歉意):我应该如何存储百分比? 在编写包含大量分析计算或涉及百分比(返回率、年利率、利润率等)的财务计算的程序时,以下三个选项中哪一个是最佳实践,就性能、可读性、
$ find -readable find: ‘./folder1’: Permission denied 假设 find 检查目录的“r”权限,就像检查文件一样, 为什么find会打印不可读的文件夹
我遇到了一个奇怪的情况,我必须把我的名字和联系信息放在网页上,我认为这很好,只要文本不能被机器人读取、复制等。 基本上我想要的是一个看起来像普通文本但表现得像图像的文本 block 。但是,我不能使用
这个问题在这里已经有了答案: How to use range-based for() loop with std::map? (5 个答案) 关闭 9 年前。 新的基于范围的 for 循环确实提高
如何在命令提示符下生成“可读”退格键? 我有一个微型 C 应用程序,我正在尝试使用 getchar() 方法从输入中读取退格键。 是否有任何组合键可以触发它(并且仍然能够捕获它)? (类似于 Ctrl
我是一名优秀的程序员,十分优秀!