相关疑难解决方法(0)

如何进行HTTP POST Web请求

如何使用该POST方法发出HTTP请求并发送一些数据?我可以做GET请求,但不知道如何制作POST.

.net c# post httpwebrequest httprequest

1033
推荐指数
10
解决办法
147万
查看次数

使用本地图像作为输入使用Google图像搜索的脚本

我正在寻找批处理或Powershell脚本,以使用本地图像作为输入在Google图像上搜索类似的图像.

在此输入图像描述

我的研究到目前为止

使用URL而不是本地文件进行图像搜索的语法如下:
https://www.google.com/searchbyimage?image_url=TEST
其中TEST可以替换为您拥有的任何图像URL.

我使用cURL for windowsimgur作为临时图像保护程序.我能够通过批量上传文件到imgur.然后使用图片网址在Google上搜索类似的图片.

但我想知道是否可以不使用像imgur或任何其他在线图片服务的任何临时缓存.只是批量,卷曲,谷歌和我.

只是一个想法.VBS脚本是否能够使用本地文件作为输入在Google图像上进行搜索?
或者像Tineye这样的类似Web服务更适合这项任务?


此PowerShell代码段将打开谷歌图像搜索.

$IE= new-object -com InternetExplorer.Application
$IE.navigate2("https://www.google.com/imghp?hl=en")
while ($IE.busy) {
sleep -milliseconds 50
}
$IE.visible=$true
Run Code Online (Sandbox Code Playgroud)

接下来的步骤是获取某些按钮的ID并以编程方式单击它们以选择本地文件.但在这里,我没有足够的经验来实现这一目标.

powershell curl batch-file google-image-search

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

给httpclient添加参数

我在 Postman 中编写了一个 HTTP 请求,我想在我的应用程序中编写相同的请求。postman 中有一个选项可以查看 C# 请求的代码。在邮递员中,它使用RestSharp显示请求,因为我不想在我的项目中使用外部 NuGet 包,所以我正在尝试使用 .NET Framework 中的对象编写相同的请求。

RestSharp 代码如下所示:

var client = new RestClient("https://login.microsoftonline.com/04xxxxa7-xxxx-4e2b-xxxx-89xxxx1efc/oauth2/token");
var request = new RestRequest(Method.POST);       
request.AddHeader("Host", "login.microsoftonline.com");            
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddParameter("undefined", "grant_type=password&client_id=6e97fc60-xxx-445f-xxxx-a9b1bbc9eb2d&client_secret=4lS*xxxxxYn%5BENP1p%2FZT%2BpqmqF4Q&resource=https%3A%2F%2Fgraph.microsoft.com&username=myNameHere%402comp.onmicrosoft.com&password=xxxxxxxxxx6", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

我尝试使用以下命令编写相同的请求HttpWebRequest

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://login.microsoftonline.com/0475dfa7-xxxxxxxx-896cf5e31efc/oauth2/token");
request.Method = "GET";
request.Referer = "login.microsoftonline.com";
request.ContentType = "application/x-www-form-urlencoded";

request.Headers.Add("grant_type", "password");
request.Headers.Add("client_id", "6e97fc60-xxxxxxxxx-a9bxxxxxb2d");
request.Headers.Add("client_secret", "4lSxxxxxxxxxxxmqF4Q");
request.Headers.Add("resource", "https://graph.microsoft.com");
request.Headers.Add("username", "xxxx@xxxxx.onmicrosoft.com");
request.Headers.Add("password", "xxxxxxxxxxxxx");

HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync();
Run Code Online (Sandbox Code Playgroud)

但我正在获取 HTML 内容,我认为我需要添加参数而不是标题,如何实现?

c# httpclient httpwebrequest

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