环境:vs2005
语言:c++
问题:怎么获得网页的HTML代码?并自动填写内容,再递交到服务器。

解决方案 »

  1.   

    你是WebBrowser 还是纯粹自己发送 http请求?
      

  2.   

    1.自己分析url,
    "http://www.163.com/fxxxboss.php"
    2.获取hostname
    www.163.com
    3.gethostbyname() 获取ip
    4.connect ip
    5.写请求头:
    GET /fxxxboss.php HTTP/1.1
    Accept:  */*
    Accept-Language: en-us
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/4.0 (compatible; MSIE 6.0)
    Host: www.163.com
    6.send, and recv
    7.读取recv内容
    HTTP/1.1 200 OK
    Date: Mon, 09 Nov 2009 12:18:43 GMT
    Server: Apache
    X-Powered-By: PHP/5.2.9
    Pragma: no-cache
    Cache-Control: no-cache, no-store, max-age=0, must-revalidate
    Expires: Sun, 01 Jan 1984 12:34:56 GMT
    Vary: Accept-Encoding
    Content-Length: 7347
    Content-Type: text/html; charset=UTF-8
    xxxxxxxxxxxxxx <-html 内容
    p.s: 注意Content-Length内容,这方面自己找资料看吧,半小时差不多都明白了.
      

  3.   

    WebBrowser 
    或是直接用 wininet都可以。
      

  4.   

    winhttp等api,先分析对应访问的http包格式,然后填好对应参数,就可以用winhttp系列API发送了