C#WebClient-从URI而不是CSV获取HTML [英] C# WebClient - Getting an HTML from URI instead of CSV

查看:43
本文介绍了C#WebClient-从URI而不是CSV获取HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用C#WebClient从以下uri获取一个csv文件.

I'm trying to get a csv file from the following uri using C# WebClient.

var copUri ="http://obieebr.banrep.gov.co/analytics/saw.dll?Go&Path=%2fshared%2fSeries%20Estad%c3%adsticas_T%2f1.%20IBR%2f1.1.IBR_CSV_XML_ultimos_datos&download_type=csv&NQUser=publico&NQPassword=publico"
var client = new WebClient();
var content = client.DownloadString(copUri);

当我在浏览器中尝试时,我得到了csv文件,但是上面的代码返回了html身份验证文件.我如何通过此html响应来获取csv文件?

When I try it in my browser I get the csv file, but the above code is returning the authentication html file instead. How do I get past this html response to get the csv file?

推荐答案

问题超出了cookie的识别范围-csv是使用浏览器中的javascript编译的.通过使用Casperjs渲染模糊的javascript,然后从基础实例获取数据来解决.

The problem was beyond the cookie awareness - the csv was compiled with javascript in the browser. Solved by using Casperjs to render the obfuscating javascript and then getting the data from the underlying instance.

这篇关于C#WebClient-从URI而不是CSV获取HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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