执行某种Web请求并获得结果 [英] Performing a some kind of Web Request and getting result

查看:64
本文介绍了执行某种Web请求并获得结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。



这是我想要互动的网站Genderchecker



我想要将值设置为网站中的特定输入元素。

单击图像元素。

获取结果 span 文本转换为字符串变量



你能给我一些建议吗?

Hello.

Here is the site that I want to interact Genderchecker

I want to set a value to a specific input element in a web site.
Perform a click on an element that is image.
Get the result span text into string variable

Can you give me advice what should I use ?

推荐答案

除了发送HTTP请求和获取HTTP响应之外,不要尝试执行任何客户端活动。这个想法是:您应该发送与浏览器相同的请求,而不是执行所有客户端站点活动。您可以使用类 System.Net.HttpWebRequest

http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest%28v=vs.110%29。 aspx [ ^ ]。



如何知道究竟要发送什么?可以有不同的方法。在简单的情况下,您可以通过使用浏览器的查看页面源功能(或类似的东西,具体取决于您的浏览器)查看其代码来了解网页的功能。您可能需要下载客户端代码的相关部分,例如脚本。



我有不同的建议。您可以获得任何合适的HTTP间谍软件。特别是,有许多产品作为插件模块实现到不同的浏览器。用一个。例如,我使用HttpFox,一个Mozilla浏览器的插件。激活HTTP跟踪并按照用户的操作在浏览器中执行所有操作。通过捕获的HTTP请求和响应,您可以弄清楚如何刮取所需的数据。另请参阅: http://en.wikipedia.org/wiki/Web_scraping [ ^ ]。



另见我过去的答案:

http://www.codeproject .com / Answers / 285975 / get-specific-data-from-web-page#answer2 [ ^ ],

如何从另一个站点获取数据 [ ^ ]。



-SA
Don't try to do any client activity except sending HTTP request and getting HTTP response. The idea is: you should sent the same requests that the browser would do, not doing all the client-site activity. You can use the class System.Net.HttpWebRequest:
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest%28v=vs.110%29.aspx[^].

How to know what exactly to send? There can be different approaches. In simple cases, you can learn what the Web page does by looking at its code using, say, browser's "View Page Source" feature (or something like that, depending on your browser). You may need to download related parts of the client-side code, such as scripts.

I have a different advice. You can get any suitable HTTP spying software. In particular, there is a number of products implemented as plug-in modules to different browsers. Use one. I, for example, use HttpFox, a plug-in to Mozilla browser. Activate HTTP trace and do all manipulations in your browser as the user would do. By captured HTTP requests and responses, you can figure out how to scrape the data you need. See also: http://en.wikipedia.org/wiki/Web_scraping[^].

See also my past answers:
http://www.codeproject.com/Answers/285975/get-specific-data-from-web-page#answer2[^],
How to get the data from another site[^].

—SA


这篇关于执行某种Web请求并获得结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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