我要从网页内容中抽出正确的图片链接。
首先从网页源文件里抽出的图片链接是“Images/hui%20hui/3/3534437a-c30a-40ce-aa10-0301be5dc3cc.jpg”
该网页的链接是“http://www.72g.com/News/523/56247_1.html”
正确的图片链接是“http://www.72g.com/Images/hui%20hui/3/3534437a-c30a-40ce-aa10-0301be5dc3cc.jpg”
我采用的方法是:
str2//网页地址
p//抽出的图片地址
int n=0;
str1=str2+p;
if(w3c.Connect(str1.c_str())){
if(w3c.Request(w3c.GetURI())){
n=1;
p=str1;
}
w3c.Close();
}
if(n==0)
{
site=str2.find("\/");
str2=str2.substr(0,site+1);
str1=str2+p;
if(w3c.Connect(str1.c_str())){
if(w3c.Request(w3c.GetURI())){
n=1;
p=str1;
}
w3c.Close();
}
if(n==0)
{
string::size_type pos1 = str.find (47,8);
pos1=str.find(47,pos1+1);
while(pos1!=string::npos)
{
str2=str.substr(0,pos1+1);
str1=str2+p;
if(w3c.Connect(str1.c_str())){
if(w3c.Request(w3c.GetURI())){
n=1;
p=str1;
}
w3c.Close();
}
if(n==1)
break;
pos1=str.find(47,pos1+1);
}
}
可最后得到的是错误的网址“http://www.72g.com/News/523/Images/hui%20hui/3/3534437a-c30a-40ce-aa10-0301be5dc3cc.jpg”
请帮我看看代码有什么问题,为什么拿不到正确的网址呢?
首先从网页源文件里抽出的图片链接是“Images/hui%20hui/3/3534437a-c30a-40ce-aa10-0301be5dc3cc.jpg”
该网页的链接是“http://www.72g.com/News/523/56247_1.html”
正确的图片链接是“http://www.72g.com/Images/hui%20hui/3/3534437a-c30a-40ce-aa10-0301be5dc3cc.jpg”
我采用的方法是:
str2//网页地址
p//抽出的图片地址
int n=0;
str1=str2+p;
if(w3c.Connect(str1.c_str())){
if(w3c.Request(w3c.GetURI())){
n=1;
p=str1;
}
w3c.Close();
}
if(n==0)
{
site=str2.find("\/");
str2=str2.substr(0,site+1);
str1=str2+p;
if(w3c.Connect(str1.c_str())){
if(w3c.Request(w3c.GetURI())){
n=1;
p=str1;
}
w3c.Close();
}
if(n==0)
{
string::size_type pos1 = str.find (47,8);
pos1=str.find(47,pos1+1);
while(pos1!=string::npos)
{
str2=str.substr(0,pos1+1);
str1=str2+p;
if(w3c.Connect(str1.c_str())){
if(w3c.Request(w3c.GetURI())){
n=1;
p=str1;
}
w3c.Close();
}
if(n==1)
break;
pos1=str.find(47,pos1+1);
}
}
可最后得到的是错误的网址“http://www.72g.com/News/523/Images/hui%20hui/3/3534437a-c30a-40ce-aa10-0301be5dc3cc.jpg”
请帮我看看代码有什么问题,为什么拿不到正确的网址呢?
解决方案 »
- 硕士论文答辩问题:udp发送数据,在数据出网卡之前,会不会丢包?
- 有哪位大哥做过输入法吗???关于完全IME感知的应用程序。
- RTP+ffmpeg mpeg4解码 求大师解答
- 急求!!!
- CFontDialog 如何改变 CEdit 字体??
- 访问数据库需要数据源,那么动网论坛和discuz 论坛程序的数据源在哪,还是根本没有?
- directshow的简单问题
- 如何单击静态文本后弹出一个对话框
- 怎么调试api函数?
- 请问哪里有关于使用Visual C++进行数据库编程的例子,或者电子书,或者图书可以下载?
- 为什么我的sdi的CMainFrame类没有这些消息?
- 网络编程高手请进!!十万火急!!
该网页的链接是“http://www.72g.com/News/523/56247_1.html”
正确的图片链接是“http://www.72g.com/Images/hui%20hui/3/3534437a-c30a-40ce-aa10-0301be5dc3cc.jpg”
-----------------------------
怎么推算出来的?