VC獲取網頁內容

2021-06-01 02:45:21 字數 1208 閱讀 3013

下面是codeguru上的乙個使用wininet類的例子,它能夠從給定的url位址中

獲取該檔案。

這個例子實現了兩個方法:

cstring getwebpage(const cstring& url);

void seterrormessage(cstring s);

getwebpage是主要的方法,後面跟的url位址必須是乙個完整的url位址,

比如seterrormessage方法, 能夠處理程式中發生的錯誤。

在vc中建立乙個類cwebworld

// cwebworld.h: inte***ce for the cwebworld class.

////

#if !defined(afx_cwebworld_h__7a9e56e1_0168_4cbf_a6bf_3fdfe5b88a73__included_)

#define afx_cwebworld_h__7a9e56e1_0168_4cbf_a6bf_3fdfe5b88a73__included_

#if _msc_ver > 1000

#pragma once

#endif // _msc_ver > 1000

#include "wininet.h"

class cwebworld 

cwebworld::~cwebworld()

cstring cwebworld::getwebpage(const cstring &url)

;dword dwlengthsizebuffer = sizeof(szsizebuffer);

dword dwfilesize;

dword dwbytesread;

bool bsuccessful;

cstring contents;

//設定莫阿人錯誤資訊

contents = m_errormessage;

//開啟url並獲取http檔案控制代碼

c 獲取網頁內容

http s34.pet.mop.com petwin.html title 檢視 nclick p.showpetinfo 0,機警小雞 49597282678812,false,false,false,true p.setfuji 0 return false 機警小雞 r nhttp s34....

php 獲取網頁內容

方法1 用file get contents 以get方式獲取內容 url html file get contents url echo html 方法2 用file get contents函式,以post方式獲取url 如果需要再傳遞cookie資料,則把 content length str...

Python requests獲取網頁內容

想要從網際網路上獲取 處理大量資訊,python的爬蟲功能是首選。很常用的搭配是 requests re 以檢測網域名稱註冊狀態為例,分享requests庫的使用 舉例 檢視網域名稱 baidu.com 的註冊狀態 輸出結果 與直接訪問該 獲得的結果相比 獲得網頁後,通常不會直接儲存整個網頁,而是從...