自动无头Web浏览 [英] Automatic Headless Web Browsing

查看:69
本文介绍了自动无头Web浏览的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示从我的应用程序中的网站检索到的信息.要访问此信息,通常需要:

I want to display information that is retrieved from a website on my app. To access this information, normally you would need to:

1.导航到登录"页面,然后输入您的用户名和密码.

1. Navigate to the log in page and enter your username and password. 

2.点击一个链接,将显示信息

2. Click a link which will display the information

我希望能够在不打开浏览器的情况下包含这些信息.基本上,用户提供了他们的登录信息,而我的应用将显示该网站将提供的信息.我知道我可以使用HttpWebRequest 要做到这一点,但这似乎有点混乱.是否可以从Windows Phone应用程序中直接实现这种无头Web自动化的方法?

I would like to be able to include the information without opening a browser. Basically the user provides their log in information and my app would display the information that the website would provide. I know I might be able to use HttpWebRequest to accomplish this, but that seems a bit messy. Is there a straightforward way to do this type of headless web automation from within a Windows Phone app?

推荐答案

每个网站唯一的.登录到一个网站可能与登录另一个网站完全不同.有些使用持久性cookie/会话,而另一些使用古怪的方法.如果您是该网站 尝试登录时没有"API"与您一起工作将需要尝试手动进行,但这并不总是可能的.

Website login procedures are unique to each website. Logging in to one website might be accomplished completely different from logging into another. Some use persistent cookies / sessions, and some use wacky methods unique to them. If the website you are trying to login to has no "API" to work with you will need to try to do it manually, which is not always possible.

如果您手动执行此操作,则您的应用必须执行浏览器在后台执行的功能(并且您将需要使用HttpWebRequest).这意味着正确将登录信息发布到网站并正确处理返回的原始数据 (设置Cookie等).

If you do it manually, your app must perform the functions the browser is performing behind the scenes (and you will need to use HttpWebRequest). This means posting the login information to the website correctly and handling the raw data returned correctly (settings cookies, etc).

通过创建将您登录到网站并显示网站页面的应用程序,您实际上是在重新创建浏览器.

By creating an app that logs you into a website and displays the website pages, you are essentially recreating a browser.


这篇关于自动无头Web浏览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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