简体   繁体   中英

how to get web sites content by some parameters?

i am using WATIN (i am using 2 days...)to get any web site's content like that:

Deault.aspx:

<body>
    <form id="form1" runat="server">
    <div>
    <asp:TextBox ID="some_textbox" runat="server"> </asp:TextBox>
    <asp:Button ID="submit_button" runat="server" Text="search" 
            onclick="submit_button_Click" />
    <asp:Label ID="lblMsg" runat="server" Text="" ></asp:Label>
    </div>
    </form>
</body>

My Client Codes via Watin(http://watin.org/documentation/getting-started/)


    private void button1_Click(object sender, EventArgs e)
        {
            //launch a new IE browser
            using (FireFox browser = new FireFox("http://localhost:3411/Default.aspx"))
            {
                //now we have access to the browser object
                //filling a textbox and clicking a button is as easy as
                browser.TextField(Find.ByName("some_textbox")).TypeText("foobar");
                browser.Button(Find.ByName("submit_button")).Click();

                //we can also access the full html of the page to perform regex matches, scrapes, etc...
                string fullPageSource = browser.Html;

            }
        }

i have 2 question:
1) i dislike to open in web browser it must be run back ground. because i will searh some data in 20-30 pages one event. PLease don't monitor me web pages every thing must run back ground
2) i am writing textbox name button name or whatelse. i don't have any idea textboxname or search button name because i will search some product in amazon. i need some trick how to make a price comparison like http://www.pricegrabber.com/ WATIN is good idea or do you have any httprequest dll or method?

Watin is designed to drive the web browser in the same way that a user would. If you don't want to open a web browser, neither Watin nor Watir is an effective solution to what you want to do. (legality issues aside).

You'll probably want to use some other means to make HTTP requests and then parse through the returned HTML, once that is you've gotten written permission from Amazon to access their site with a data gathering tool, since doing so without the permission is against their conditions of use.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM