Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static IEnumerator aSyncSearchForModel(string searchterm, MineMain root){
- WebClient w = new WebClient();
- string htmlstring = w.DownloadString("http://sketchup.google.com/3dwarehouse/doadvsearch?title="+searchterm
- +"&scoring=d&btnG=Search+3D+Warehouse&dscr=&tags=&styp=m&complexity=any_value&file="
- +"zip"+"&stars=any_value&nickname=&createtime=any_value&modtime=any_value&isgeo=any_value&addr=&clid=");
- HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
- doc.LoadHtml(htmlstring);
- //Grab a result from the search page
- HtmlAgilityPack.HtmlNodeCollection results = doc.DocumentNode.SelectNodes("//div[@class='searchresult']");
- string model_page_url = "http://sketchup.google.com"+results[0].SelectSingleNode(".//a").Attributes["href"].Value;
- htmlstring = w.DownloadString(model_page_url);
- doc.LoadHtml(htmlstring);
- //Find the downloadable zip file
- results = doc.DocumentNode.SelectNodes("//a[contains(@href,'rtyp=zip')]");
- string url = "http://sketchup.google.com"+WWW.UnEscapeURL(results[0].Attributes["href"].Value);
- url = url.Replace("&", "&");
- UnityEngine.Debug.Log (WWW.EscapeURL(results[0].Attributes["href"].Value));
- UnityEngine.Debug.Log (url);
- WWW model_zip = new WWW(url);
- yield return model_zip;
- string file_loc = "path/to/downloads/"+searchterm+".zip";
- System.IO.FileStream filestream = new System.IO.FileStream(file_loc, System.IO.FileMode.Create, System.IO.FileAccess.Write); //Assets/Resources/sfx/
- filestream.Write (model_zip.bytes, 0, model_zip.bytes.Length);
- filestream.Close();
- }
Add Comment
Please, Sign In to add comment