我要从网页内容中抽出正确的图片链接。
首先从网页源文件里抽出的图片链接是“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”
请帮我看看代码有什么问题,为什么拿不到正确的网址呢?