我想作一个能自动登录网站指定页面的小东东,比如能每天自动--》登录CSDN,输入账号,更新我的个人信息等......

解决方案 »

  1.   

    以下形成html文件就可
    <html>
    <head>
    <title>net fava</title>
    <body><form  method="POST" action="http://expert.csdn.net/member/logon.asp" target="_top" name="alogon">

            <input type="text" name="name" size="7" value="">
            <input type="password" name="pass" size="7" value="">
            
            <select  name="type" size="1" style="background-color:#006699;color:#ffffff">
            <option value="1" selected>我的论坛</option>
            <option value="2">我的软件</option>
            <option value="3">我的订单</option>
            <option value="4">我的文档</option>
            <option value="5">我的简历</option>
            </select>
            <input type="image" src="http://www.csdn.net/images/index_login1.gif">
    </form>
    </body>
    </html>
    在两个value的地方填写你的用户名和密码即可
    如果想用C的话,可以用编个以上的网页在webbrowser或是直接发送http请求都可
      

  2.   

    如果想控制IE中的提交,参照如下:
    void CGetIESrcDlg::NavigateToUrl()
    {
    // Import the following files in your stdafx.h
    // #import <mshtml.tlb> // Internet Explorer 5
    // #import <shdocvw.dll>
    //  Refer to "Connect to Internet Explorer Instances, From your own Process. " in www.codeguru.com
    SHDocVw::IShellWindowsPtr m_spSHWinds;
    CoInitialize(NULL);
    if(m_spSHWinds.CreateInstance(__uuidof(SHDocVw::ShellWindows)) == S_OK)
    {
    IDispatchPtr spDisp;
    long nCount = m_spSHWinds->GetCount();
    for (long i = 0; i < nCount; i++)
    {
    _variant_t va(i, VT_I4);
    spDisp = m_spSHWinds->Item(va);
    SHDocVw::IWebBrowser2Ptr spBrowser(spDisp);
    if (spBrowser != NULL)
    {
    IDispatchPtr spDisp;
    if(spBrowser->get_Document(&spDisp) == S_OK && spDisp!= 0 )
    {
    MSHTML::IHTMLDocument2Ptr spHtmlDocument(spDisp);
    MSHTML::IHTMLElementPtr spHtmlElement;
    if(spHtmlDocument==NULL)
    continue;
    spHtmlDocument->get_body(&spHtmlElement);
    if(spHtmlDocument==NULL)
    continue;
    HRESULT hr;
    MSHTML::IHTMLElementCollection* pColl=NULL;
    hr=spHtmlDocument->get_all(&pColl);
    if(pColl!=NULL&&SUCCEEDED(hr))
    {
    MSHTML::IHTMLElement* pElem=NULL;
    _variant_t index;
    index.vt=VT_I4;
    index.intVal=0;
    _variant_t name("Submit");
    IDispatchPtr disp;
    disp=pColl->item(name,index);
    if(disp==NULL)
    hr=E_FAIL;
    else
    {
    hr=disp->QueryInterface(&pElem);
    }
    if (SUCCEEDED(hr)&& pElem != NULL)
    {
    //
    BSTR bstrhtml;
    pElem->get_outerHTML(&bstrhtml);
    CString str(bstrhtml);
    AfxMessageBox(str);
    pElem->click();
    pElem->Release();
    }
    pColl->Release();
    }
    } }
    } }
    else {
    AfxMessageBox("Shell Windows interface is not avilable");
    }
    CoUninitialize();
    }