标签: webclient-download

将WebClient与socks代理一起使用

有没有办法使用socks代理WebClient?特别DownloadString是它提供的方法?

我不想使用任何第三方的东西,如privoxy,freecap,我不能使用像Chilkat那样的商业库.我尝试使用来自http://www.mentalis.org/的东西,实际上我使用了它们的WebRequest实现,但它们似乎没有类似于WebClient的东西.

.net c# webclient socks webclient-download

20
推荐指数
5
解决办法
2万
查看次数

如何将默认凭据传递给PowerShell Web客户端对象?替代PS v2的Invoke-WebRequest?

我正在运行以下代码

$client = new-object System.Net.WebClient
$client.DownloadFile( $UriValue, "C:\Temp\BHRout.json" )
$json = Get-Content "C:\Temp\BHRout.json"
Run Code Online (Sandbox Code Playgroud)

这不起作用,因为它需要我的提示凭据传递到下载字符串函数.我用上面的代码替换了这个:

$NagiosResults = Invoke-WebRequest -Uri $Uri -UseDefaultCredentials | ConvertFrom-Json
Run Code Online (Sandbox Code Playgroud)

唯一的问题是我运行脚本的服务器没有Powershell v3; 所以这也行不通.Invoke-WebRequestPowershell v2 有替代品吗?如果没有,有没有办法与System.Net.WebClient对象'使用默认凭据'?

powershell powershell-2.0 webclient-download powershell-3.0

12
推荐指数
1
解决办法
2万
查看次数

有没有办法在PowerShell中使用WebClient对象监视下载的进度?

我正在使用如下简单的行下载文件:

$webclient = New-Object -TypeName System.Net.WebClient
$webclient.DownloadFile("https://www.example.com/file", "C:/Local/Path/file")
Run Code Online (Sandbox Code Playgroud)

问题是我想在下载时使用弹出窗口或使用shell中的进度条向用户显示消息.下载完成时是否可以使弹出框消失,或者监视下载进度的进度条是否可以?

powershell webclient powershell-2.0 webclient-download

9
推荐指数
2
解决办法
1万
查看次数

下载网站中的所有文件

我需要下载此链接下的所有文件,其中只有郊区名称在每个链接中不断变化

只是一个参考 https://www.data.vic.gov.au/data/dataset/2014-town-and-community-profile-for-thornbury-suburb

此搜索链接下的所有文件:https: //www.data.vic.gov.au/data/dataset?q = 2014+town+and+community+profile

任何可能性?

谢谢 :)

python r download webclient-download

9
推荐指数
1
解决办法
7400
查看次数

如果文件已存在于磁盘上,WebClient.DownloadFileAsync是否会覆盖该文件?

我无法找到有关我的问题的任何信息.如果我的搜索工作不够好,无法找到答案,请原谅.我只是想避免旋转我的车轮.

谢谢!

跟进:如果没有覆盖,我该怎么办?(如果可能的话)?

c# asynchronous webclient-download

8
推荐指数
1
解决办法
7776
查看次数

C#使用带有DownloadFileAsync的StreamReader从文件读取行

我在使用StreamReaderline != null添加时读取文件时遇到问题textBox1

码:

using(StreamReader reader = new StreamReader("lastupdate.txt"))
{
    string line;

    while((line = reader.ReadLine()) != null)
    {
        textBox1.Text = line;
    }

    reader.Close();
}
Run Code Online (Sandbox Code Playgroud)

它不起作用,我不知道为什么.我尝试使用using StreamReader,我从URL下载文件,我可以在文件夹中看到该文件已下载.该lastupdate.txt是大小1KB.

这是我当前的工作代码MessageBox.如果我删除MessageBox,代码不起作用.它需要某种等待或我不知道:

WebClient client = new WebClient();

client.DownloadFileAsync(new Uri(Settings.Default.patchCheck), "lastupdate.txt"); // ok

if(File.Exists("lastupdate.txt"))
{
    MessageBox.Show("Lastupdate.txt exist");
    using(StreamReader reader = new StreamReader("lastupdate.txt"))
    {
        string line;

        while((line = reader.ReadLine()) != null)
        {
            textBox1.Text = line;
            MessageBox.Show(line.ToString());
        }

        reader.Close();
    }

    File.Delete("lastupdate.txt");
}
Run Code Online (Sandbox Code Playgroud)

c# readline streamreader webclient-download

7
推荐指数
2
解决办法
8万
查看次数

使用C#API从Facebook下载附件

我可以使用FB API从facebook对话下载图像,但现在我有一个问题是使用图表FB API从facebook下载附件(.doc,.txt,.log等).

如果附加文件如下,Json结果由Facebook返回:

"message":"test sent attachment","attachments":{"data":[{"id":"10203275664207489","mime_type":"application/octet-stream","name":"service.log","size":432}]}},
Run Code Online (Sandbox Code Playgroud)

哪个没有任何URL链接到该文件.但对于json返回的图像包含该图片的网址.见下面的Json:

"message":"Gambaq","attachments":{"data":[{"id":"10203185045102068","mime_type":"image/jpeg","name":"10391434_10203185044782060_6466381862586755357_n.jpg","size":null,"image_data":{"width":720,"height":960,"is_sticker":false,"url":"https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-xpt1/v/t34.0-12/11304104_10203185045102068_881196838_n.jpg?
Run Code Online (Sandbox Code Playgroud)

我使用此API代码获取Json结果:

    dynamic resultsByApi = fb.Get("/" + fbFanPage + "/conversations?access_token=" + tokenPage + "");
Run Code Online (Sandbox Code Playgroud)

我的问题是,有人知道如何使用FB API获取Facebook对话的附加文件URL吗?

任何人都可以帮我解决这个问题.先谢谢你.

c# facebook download facebook-graph-api webclient-download

7
推荐指数
1
解决办法
1167
查看次数

连接尝试失败,因为连接方在一段时间后没有正确响应或连接的主机未能响应

我正在开发一个 Windows 服务,它从特定的 URL 下载图像。该服务在我的计算机上正常运行,但是当我将其安装在服务器中时,它不会下载图像并出现以下错误:

System.Net.WebException: 无法连接到远程服务器 ---> System.Net.Sockets.SocketException: 连接尝试失败,因为连接方在一段时间后没有正确响应,或者由于连接的主机而建立连接失败未能响应 212.100.220.117:80

在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)

在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)

--- 内部异常堆栈跟踪结束 ---

在 System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) at System.Net.WebClient.DownloadData(Uri address) at System.Net.WebClient.DownloadData(String address)

什么可能导致错误,我该如何解决?我读了这个页面:http : //support.microsoft.com/kb/318140

但我不确定这是否是问题所在,如果是我应该在配置中写入什么代理。征求你的意见。

谢谢,

c# windows-services webclient windows-server webclient-download

6
推荐指数
1
解决办法
6万
查看次数

如何用HttpClient替换WebClient?

我的asp.net mvc Web应用程序中有以下WebClient:

using (WebClient wc = new WebClient()) // call the Third Party API to get the account id 
{
     string url = currentURL + "resources/" + ResourceID + "/accounts?AUTHTOKEN=" + pmtoken;
     var json = await wc.DownloadStringTaskAsync(url);
 }
Run Code Online (Sandbox Code Playgroud)

那么有人可以建议我如何将它从WebClient更改为HttpClient?

.net webclient webrequest webclient-download

6
推荐指数
1
解决办法
8447
查看次数

从基于Flask的Python服务器下载文件

我正在努力使工作成为我在此URL中找到的代码:http://code.runnable.com/UiIdhKohv5JQAAB6/how-to-download-a-file-generated-on-the-fly-in-flask-换蟒蛇

我的目标是当用户访问基于Flask的Python服务器上的Web服务时,能够在Web浏览器上下载文件.

所以我写了下面的代码:

@app.route("/api/downloadlogfile/<path>")
def DownloadLogFile (path = None):
    if path is None:
        self.Error(400)

    try:
        with open(path, 'r') as f:
            response  = make_response(f.read())
        response.headers["Content-Disposition"] = "attachment; filename=%s" % path.split("/")[2]

        return response
    except Exception as e:
        self.log.exception(e)
        self.Error(400)
Run Code Online (Sandbox Code Playgroud)

但是这段代码似乎不起作用.确实,我得到了一个我无法解决的错误:

Traceback (most recent call last):
File "C:\Python27\lib\site-packages\gevent\pywsgi.py", line 508, in handle_one_response
self.run_application()
File "C:\Python27\lib\site-packages\geventwebsocket\handler.py", line 88, in run_application
return super(WebSocketHandler, self).run_application()
File "C:\Python27\lib\site-packages\gevent\pywsgi.py", line 495, in run_application
self.process_result()
File "C:\Python27\lib\site-packages\gevent\pywsgi.py", line 484, in process_result
for data in self.result:
File …
Run Code Online (Sandbox Code Playgroud)

python werkzeug flask webclient-download

6
推荐指数
1
解决办法
2万
查看次数