0
这是link我有一个包含具有格式的数据的大名单:如何搜索并从原始网页中获取文本? VC++?
“X = MapNumber:Y = MAPNAME”
例如
“10000:蘑菇园”。
在vC++ .net中,我想编写一个连接到该链接的函数,在数据中搜索一个数字(比方说10000),然后在数字旁边获得名称(这将是蘑菇公园),然后把名字放入一个字符串中。
下面的代码是我已经和将工作,如果所有的数据都在.txt文件中,但我想将此代码转换为连接到上面的链接,并最终使其更有效。
谢谢。
String^ GrabMapNameById(String^ CurrentStr)//Current Map String{
if(CurrentMapIDRead.ToString() != CurrentMapID.ToString()) //If map has chnaged
{
try //Try streaming text
{
String^ Maps = "Strife.Maps";//map File Name
StreamReader^ MapDin = File::OpenText("Strife.Maps");//Stream Declar
String^ str;
string s;
int count = 0;
while ((str = MapDin->ReadLine()) != nullptr) //Loop for every line
{
if(str->Contains(CurrentMapID.ToString())) //Untill Map id found
{
CurrentMapIDRead = CurrentMapID; //Set Current Map Name
CurrentStr = str->Replace(CurrentMapIDRead.ToString() , "");//Replace map id with null characters
CurrentStr = CurrentStr->Replace(" =" , ""); //Take out = characters
break;// kill while
}
}
}
catch (Exception^ e)
{
}
}return CurrentStr;}
如果可能,请查找[libcurl](http://curl.haxx.se/libcurl/)。 Windows二进制文件可用。 – 2012-07-16 05:06:49