以编程方式导航站点

发布于 2024-09-09 09:42:33 字数 506 浏览 1 评论 0原文

我目前正在开发一个项目,我必须以编程方式导航网站。我正在使用 C#。在某些情况下,网站会根据控件的事件进行导航(更改页面内容),而 URL 保持不变。就像下面的

http://www. centurysecuritiesng.com/Home/tabid/36/ctl/listing/mid/410/Default.aspx

在此页面上有一个下拉列表(价目表如上所示),并且页面内容随着下拉项目的更改而变化,而页面的 URL 保持不变。任何人都可以建议我如何以编程方式实现此目的,意味着动态更改下拉项并根据该下拉项获取其内容。

简而言之,我想要基于某个值来对抗控件事件的页面的动态内容。在我的例子中,这是基于下拉列表的选定值的 dropdrown 的 onchange 事件

提前致谢。

I am currently working on a project for which i have to navigate site programmatically. I am using C#. In some case sites navigates(change contents of page) on the event of a control, while URL remain same. like the one below

http://www.centurysecuritiesng.com/Home/tabid/36/ctl/listing/mid/410/Default.aspx

On this page there is a dropdown(Price List as at) and the content of the page changes on dropdown item change, while URL of the page remain same. can anybody suggest that how can i achieve this programmatically, mean changing dropdown item dynamically and getting its content against that dropdown item.

In short i want dynamic content of the page which is coming against event of a control, based on some value. Which in my case is onchange event of dropdrown based on selected value of the dropdown

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

温柔嚣张 2024-09-16 09:42:33

您可以尝试使用硒。看一下:http://seleniumhq.org/。此外,您可以用您选择的多种语言编写网络爬虫。如果您更喜欢 .NET,请查看 HttpWebRequestClass。

You can try with Selenium. Take a look at: http://seleniumhq.org/. Also, you can write web crawler in many languages of your choice. If you prefer .NET, take a look at HttpWebRequestClass.

沫雨熙 2024-09-16 09:42:33

从您的问题中尚不清楚,但我假设您正在尝试使您的 C# 应用程序自动化作为单独应用程序运行的 Web 浏览器(而不是在您的应用程序中嵌入 WebBrowser 控件并使其自动化)。

这听起来像是 WatiN 旨在自动化的事情。它旨在用于自动化测试(这可能是也可能不是您正在做的事情),但为您提供了一种简单的方法来驱动 IE 或 FireFox 的外部实例、导航到页面、查找文本字段并在其中键入、单击按钮、等等。

来自他们网站的示例代码片段:

using (var browser = new IE("http://www.google.com"))
{
    browser.TextField(Find.ByName("q")).TypeText("WatiN");
    browser.Button(Find.ByName("btnG")).Click();

    Assert.IsTrue(browser.ContainsText("WatiN"));
}

It's not clear from your question, but I assume you're trying to make your C# app automate a Web browser that's running as a separate application (as opposed to embedding a WebBrowser control in your app and automating that).

This sounds like the sort of thing WatiN is meant to automate. It's intended for automated tests (which may or may not be what you're doing) but gives you an easy way to drive an external instance of either IE or FireFox, navigate to pages, find text fields and type into them, click buttons, etc.

A sample code snippet from their site:

using (var browser = new IE("http://www.google.com"))
{
    browser.TextField(Find.ByName("q")).TypeText("WatiN");
    browser.Button(Find.ByName("btnG")).Click();

    Assert.IsTrue(browser.ContainsText("WatiN"));
}
淑女气质 2024-09-16 09:42:33

我认为您正在尝试进行页面抓取。如果是,那么 HTML Agility Pack 是您在 .NET 应用程序中使用并以编程方式废弃页面的最佳选择。

I think you are trying to do page scraping. If yes then HTML Agility Pack is best choice for you to use in your .NET application and scrap the page programmatically.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文