private string GetShortURLDetails(string url) { string shortURL = string.Empty; try { var item = entities.urls.FirstOrDefault(e => e.real_url == url); if (item == null) { url values = new url(); values.real_url = url; values.short_url = Utility.shortenIt(url); entities.urls.Add(values); entities.SaveChanges(); shortURL = values.short_url; } else { shortURL = item.short_url; } } catch (Exception ex) { } return(shortURL); }
public logStatement(string statement) { IpAddress = ipAddress.Create(Utils.GetIdentifier(ref statement)); UserIdentifier = userIdentifier.Create(Utils.GetIdentifier(ref statement)); User = user.Create(Utils.GetIdentifier(ref statement)); Utils.Trim(ref statement); if (statement[0] == '[') { statement = statement.Substring(1); } else { throw new LogParseException("Cannot read timestamp, expecting \'[\', but could not find"); } Timestamp = timestamp.Create(Utils.GetIdentifier(ref statement, ']')); Utils.Trim(ref statement); if (statement[0] == '\"') { statement = statement.Substring(1); } else { throw new LogParseException("Cannot read url, expecting \'\"\', but could not find"); } Url = url.Create(Utils.GetIdentifier(ref statement, '\"')); Response = Utils.GetNumber(ref statement, "Response"); Size = Utils.GetNumber(ref statement, "Size"); }
internal List <url> EstatisticasUsuario(int id) { List <url> lista = new List <url>(); try { string qryEstatisticas = @"SELECT u.id, r.user, url, shorturl, hits FROM tb_urls u INNER JOIN tb_users r ON u.user = r.id WHERE r.id = " + id; DataTable reader = RS(qryEstatisticas); foreach (DataRow row in reader.Rows) { url url = new url(); url.Id = Convert.ToInt32(row["id"].ToString()); url.User = row["user"].ToString(); url.Url = row["url"].ToString(); url.Shorturl = row["shorturl"].ToString(); url.Hits = Convert.ToInt32(row["hits"].ToString()); lista.Add(url); } } catch (Exception erro) { throw erro; } return(lista); }
public int Edit(url url_) { try { this.urlContext.Entry(url_).State = EntityState.Modified; this.urlContext.SaveChanges(); return(1); } catch (Exception ex) { throw; } }
protected string GenerateSiteMap(List <SiteMapUrl> siteMapItems, int startIndex, int count) { urlset siteMap = new urlset(); url url; List <url> urlList = new List <url>(); int endIndex = startIndex + count; SiteMapUrl urlItem; for (int i = startIndex; i < endIndex; i++) { urlItem = siteMapItems[i]; url = new url(); url.loc = urlItem.Location; if (urlItem.LastModified != DateTime.MinValue) { url.lastmod = urlItem.LastModified.ToString("yyyy-MM-ddTHH:mm:sszzzzzz"); } if (urlItem.ChangeFrequencySpecified) { url.changefreqSpecified = true; url.changefreq = urlItem.ChangeFrequency; } else { url.changefreqSpecified = false; } if (urlItem.Priority >= 0 && urlItem.Priority <= 1) { url.priority = urlItem.Priority; url.prioritySpecified = true; } else { url.prioritySpecified = false; } urlList.Add(url); } siteMap.url = urlList.ToArray(); return(XmlUtility.Utf8BytesToString(XmlUtility.Serialize(siteMap))); }
public int Create(url _url) { try { if (_url.createdDate == null) { _url.createdDate = DateTime.Now; } generateShorUrl(_url); this.urlContext.urls.Add(_url); this.urlContext.SaveChanges(); return(_url.id); } catch { throw; } }
public void Update(url Url, timestamp Timestamp) { if (Url.Valid()) { Registry.Increment(Url.GetSection()); string outKey = KeyCache.Put(Url.GetSection()); if (outKey != null) { Registry.Remove(outKey); } } if (Timestamp.Valid()) { queue.Enqueue(Timestamp.GetValue()); } }
public IActionResult Index(string url) { // реализоывать обработку ошибок List <url> urls = new List <url>(this.urlContext.urls); url a = urls.Find(x => x.shortUrl.Equals(url)); if (a != null && !string.IsNullOrEmpty(a.longUrl)) { a.countLink++; this.urlContext.SaveChangesAsync(); return(Redirect(a.longUrl)); } else { // выводить ошибку, что записи, к сожалени нет return(Redirect("/")); } }
internal stats Estatisticas() { stats Retorno = new stats(); try { string qryEstatisticas = @"SELECT COUNT(id) AS urls, SUM(hits) AS total FROM tb_urls"; DataTable reader = RS(qryEstatisticas); if (reader.Rows.Count > 0) { if (reader.Rows[0]["total"].ToString() != "") { Retorno.UrlCount = Convert.ToInt16(reader.Rows[0]["urls"]); Retorno.Hits = Convert.ToInt16(reader.Rows[0]["total"]); Retorno.TopUrls = new List <url>(); qryEstatisticas = @"SELECT u.id, r.user AS user, url, shorturl, hits FROM tb_urls u INNER JOIN tb_users r ON u.user = r.id ORDER BY hits DESC, u.id LIMIT 10"; reader = RS(qryEstatisticas); foreach (DataRow row in reader.Rows) { url url = new url(); url.Id = Convert.ToInt32(row["id"].ToString()); url.User = row["user"].ToString(); url.Url = row["url"].ToString(); url.Shorturl = row["shorturl"].ToString(); url.Hits = Convert.ToInt32(row["hits"].ToString()); Retorno.TopUrls.Add(url); } } else { Retorno.UrlCount = 0; Retorno.Hits = 0; Retorno.TopUrls = new List <url>(); } } } catch (Exception erro) { throw erro; } return(Retorno); }
public int Delete(int?id) { try { if (id == null) { throw new Exception(); } url url_ = this.urlContext.urls.Find(id); if (url_ != null) { this.urlContext.urls.Remove(url_); this.urlContext.SaveChanges(); } return(1); } catch { throw; } }
private void generateShorUrl(url _url) { try { int firsChar; string code = ""; Random random = new Random(DateTime.Now.Second); firsChar = random.Next() % 8 + 1; code = Guid.NewGuid().ToString("n").Substring(0, 4); int ind = 0; while (this.urlContext.urls.FirstOrDefault(x => x.shortUrl.Equals(firsChar.ToString() + code)) != null && ind < 9) { firsChar = (firsChar + 1) % 8 + 1; ind++; } _url.shortUrl = firsChar.ToString() + code; } catch (Exception ex) { } }
internal url EstatisticasUrl(int id) { url Url = new url(); try { string qryUrl = @"SELECT id, user, url, shorturl, hits FROM tb_urls WHERE id = " + id; DataTable reader = RS(qryUrl); if (reader.Rows.Count > 0) { Url.Id = Convert.ToInt16(reader.Rows[0]["id"]); Url.User = reader.Rows[0]["user"].ToString(); Url.Url = reader.Rows[0]["url"].ToString(); Url.Shorturl = reader.Rows[0]["shorturl"].ToString(); Url.Hits = Convert.ToInt16(reader.Rows[0]["hits"]); } } catch (Exception erro) { throw erro; } return(Url); }
private void CreateSiteMap(SortedDictionary <string, HelpEntity> topicsAndAnchors) { SortedDictionary <string, url> dictionaryOfUrl = new SortedDictionary <string, url>(); url url; Topic topic; string topicTitle; url = new url(); url.loc = Properties.Settings.Default.website; url.priority = (decimal)1; url.prioritySpecified = true; url.changefreq = changefreq.monthly; url.changefreqSpecified = true; url.lastmod = System.DateTime.Now.Date.ToString("yyyy\"-\"MM\"-\"dd"); dictionaryOfUrl.Add("AAARootElement", url); foreach (HelpEntity he in topicsAndAnchors.Values) { topic = he as Topic; url = new url(); topicTitle = topic.TopicsTitle.Replace(" ", ""); url.loc = Properties.Settings.Default.website + "?topic=" + "html/" + topic.TopicsGuid.ToString() + ".htm"; url.priority = (decimal)0.8; url.prioritySpecified = true; url.changefreq = changefreq.monthly; url.changefreqSpecified = true; url.lastmod = System.DateTime.Now.Date.ToString("yyyy\"-\"MM\"-\"dd"); if (!dictionaryOfUrl.ContainsKey(topicTitle)) { dictionaryOfUrl.Add(topicTitle, url); } } urlset urlSet = new urlset(dictionaryOfUrl); FileInfo siteMapFile = new FileInfo(builder.OutputFolder.ToString() + "/" + Properties.Settings.Default.SiteMapFile); urlSet.WriteToXML(siteMapFile); }
public urlset GetGoogleSiteMap() { urlset root = new urlset(); root.url = new urlCollection(); //Default first... url basePage = new url(dasBlogSettings.GetBaseUrl(), DateTime.Now, changefreq.daily, 1.0M); root.url.Add(basePage); //Archives next... url archivePage = new url(dasBlogSettings.RelativeToRoot("archives"), DateTime.Now, changefreq.daily, 1.0M); root.url.Add(archivePage); //All Pages EntryCollection entryCache = dataService.GetEntries(false); foreach (Entry e in entryCache) { if (e.IsPublic) { //Start with a RARE change freq...newer posts are more likely to change more often. // The older a post, the less likely it is to change... changefreq freq = changefreq.daily; //new stuff? if (e.CreatedLocalTime < DateTime.Now.AddMonths(-9)) { freq = changefreq.yearly; } else if (e.CreatedLocalTime < DateTime.Now.AddDays(-30)) { freq = changefreq.monthly; } else if (e.CreatedLocalTime < DateTime.Now.AddDays(-7)) { freq = changefreq.weekly; } if (e.CreatedLocalTime > DateTime.Now.AddDays(-2)) { freq = changefreq.hourly; } //Add comments pages, since comments have indexable content... // Only add comments if we aren't showing comments on permalink pages already if (dasBlogSettings.SiteConfiguration.ShowCommentsWhenViewingEntry == false) { url commentPage = new url(dasBlogSettings.GetCommentViewUrl(e.CompressedTitle), e.CreatedLocalTime, freq, 0.7M); root.url.Add(commentPage); } //then add permalinks url permaPage = new url(dasBlogSettings.RelativeToRoot(dasBlogSettings.GetPermaTitle(e.CompressedTitle)), e.CreatedLocalTime, freq, 0.9M); root.url.Add(permaPage); } } //All Categories CategoryCacheEntryCollection catCache = dataService.GetCategories(); foreach (CategoryCacheEntry cce in catCache) { if (cce.IsPublic) { url catPage = new url(dasBlogSettings.GetCategoryViewUrl(cce.Name), DateTime.Now, changefreq.weekly, 0.6M); root.url.Add(catPage); } } return(root); }
public void ProcessRequest(HttpContext context) { try { //Cache the sitemap for 12 hours... string CacheKey = "GoogleSiteMap"; DataCache cache = CacheFactory.GetCache(); urlset root = cache[CacheKey] as urlset; if (root == null) //we'll have to build it... { ILoggingDataService logService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext()); IBlogDataService dataService = BlogDataServiceFactory.GetService(SiteConfig.GetContentPathFromCurrentContext(), logService); SiteConfig siteConfig = SiteConfig.GetSiteConfig(); root = new urlset(); root.url = new urlCollection(); //Default first... url basePage = new url(SiteUtilities.GetBaseUrl(siteConfig), DateTime.Now, changefreq.daily, 1.0M); root.url.Add(basePage); url defaultPage = new url(SiteUtilities.GetStartPageUrl(siteConfig), DateTime.Now, changefreq.daily, 1.0M); root.url.Add(defaultPage); //Archives next... url archivePage = new url(SiteUtilities.RelativeToRoot(siteConfig, "archives.aspx"), DateTime.Now, changefreq.daily, 1.0M); root.url.Add(archivePage); //All Pages EntryCollection entryCache = dataService.GetEntries(false); foreach (Entry e in entryCache) { if (e.IsPublic) { //Start with a RARE change freq...newer posts are more likely to change more often. // The older a post, the less likely it is to change... changefreq freq = changefreq.daily; //new stuff? if (e.CreatedLocalTime < DateTime.Now.AddMonths(-9)) { freq = changefreq.yearly; } else if (e.CreatedLocalTime < DateTime.Now.AddDays(-30)) { freq = changefreq.monthly; } else if (e.CreatedLocalTime < DateTime.Now.AddDays(-7)) { freq = changefreq.weekly; } if (e.CreatedLocalTime > DateTime.Now.AddDays(-2)) { freq = changefreq.hourly; } //Add comments pages, since comments have indexable content... // Only add comments if we aren't showing comments on permalink pages already if (siteConfig.ShowCommentsWhenViewingEntry == false) { url commentPage = new url(SiteUtilities.GetCommentViewUrl(siteConfig, e.EntryId), e.CreatedLocalTime, freq, 0.7M); root.url.Add(commentPage); } //then add permalinks url permaPage = new url(SiteUtilities.GetPermaLinkUrl(siteConfig, (ITitledEntry)e), e.CreatedLocalTime, freq, 0.9M); root.url.Add(permaPage); } } //All Categories CategoryCacheEntryCollection catCache = dataService.GetCategories(); foreach (CategoryCacheEntry cce in catCache) { if (cce.IsPublic) { url catPage = new url(SiteUtilities.GetCategoryViewUrl(siteConfig, cce.Name), DateTime.Now, changefreq.weekly, 0.6M); root.url.Add(catPage); } } cache.Insert(CacheKey, root, DateTime.Now.AddHours(12)); } XmlSerializer x = new XmlSerializer(typeof(urlset)); x.Serialize(context.Response.OutputStream, root); context.Response.ContentType = "text/xml"; } catch (Exception exc) { ErrorTrace.Trace(System.Diagnostics.TraceLevel.Error, exc); } }
/// <summary> /// Inserts an element into the urlCollection at the specified index /// </summary> /// <param name="index"> /// The index at which the url is to be inserted. /// </param> /// <param name="value"> /// The url to insert. /// </param> public virtual void Insert(int index, url value) { this.List.Insert(index, value); }
/// <summary> /// Determines whether a specfic url value is in this urlCollection. /// </summary> /// <param name="value"> /// The url value to locate in this urlCollection. /// </param> /// <returns> /// true if value is found in this urlCollection; /// false otherwise. /// </returns> public virtual bool Contains(url value) { return this.List.Contains(value); }
/// <summary> /// Adds an instance of type url to the end of this urlCollection. /// </summary> /// <param name="value"> /// The url to be added to the end of this urlCollection. /// </param> public virtual void Add(url value) { this.List.Add(value); }
return(Request(url, parameters, GET));
return((await BaseGetAsync(url, encoding, cookie: cookie, referer: referer, timeoutSeconds: timeoutSeconds, addHeaders: addHeaders, MaxResponseContentBufferSize: MaxResponseContentBufferSize)).content);
=> await DeleteAsync <JObject>(url, query, client);
/// <summary> /// Initializes a new instance of the urlCollection class, containing elements /// copied from an array. /// </summary> /// <param name="items"> /// The array whose elements are to be added to the new urlCollection. /// </param> public urlCollection(url[] items) { this.AddRange(items); }
ConfigureKillMessage(message, request, url, kill.RaidId, kill.KilledAt, teamName, encounterName, drops);
/// <summary> /// Adds the elements of an array to the end of this urlCollection. /// </summary> /// <param name="items"> /// The array whose elements are to be added to the end of this urlCollection. /// </param> public virtual void AddRange(url[] items) { foreach (url item in items) { this.List.Add(item); } }
protected void Button2_Click(object sender, EventArgs e) { try { List <url> urlList = null; urlset urlsetList = new urlset(); ArrayList listinfo = GetWebModelInfo(); urlList = new List <url>(); for (int i = 0; i < listinfo.Count; i++) { WebSiteInfo webInfo = listinfo[i] as WebSiteInfo; List <display> displayList = new List <display>(); display display = new display(); display.website = "爱购114"; display.siteurl = "http://www.xxxxx.com/"; //城市名称 display.city = webInfo.cityName; //商品标题 display.webSitetitle = webInfo.title; //商品图片 display.image = "http://211.155.235.30/tuangou/" + webInfo.folderName + "/" + webInfo.productimg; //商品开始时间 display.startTime = webInfo.begin_time.ToShortDateString(); //商品结束时间 display.endTime = webInfo.end_time.ToShortDateString(); //市场价 display.value = Convert.ToDouble(webInfo.market_price); //团购价 display.price = Convert.ToDouble(webInfo.team_price); //折扣价 display.rebate = Convert.ToDouble(webInfo.zhekou_price); //现在购买的人数 display.bought = webInfo.nownumber; displayList.Add(display); List <data> dataList = new List <data>(); data data = new data(); data.displayList = displayList; dataList.Add(data); url url = new url(); url.loc = String.Format("http://www.xxxxx.com/todaydetials.aspx?id={0}", webInfo.productID.ToString()); url.dataList = dataList; urlList.Add(url); urlsetList.urlList = urlList; } try { XmlSerializerNamespaces xmlns = new XmlSerializerNamespaces(); xmlns.Add(String.Empty, String.Empty); //构造字符串 StringBuilder sb = new StringBuilder(); //将字符串写入到stringWriter对象中 StringWriter sw = new StringWriter(sb); //xml序列化对象 typeof(类名) XmlSerializer ser = new XmlSerializer(typeof(urlset)); //把Stream对象和urlset一起传入,序列化出一个字符串sb ser.Serialize(sw, urlsetList, xmlns); sw.Close(); string FILE_NAME = HttpContext.Current.Server.MapPath("test.xml"); FileInfo fi = new FileInfo(FILE_NAME); //如果文件己经存在则删除该文件 if (fi.Exists) { if (fi.Attributes.ToString().IndexOf("ReadOnly") >= 0) { fi.Attributes = FileAttributes.Normal; } File.Delete(fi.Name); } //创建文件 并写入字符串 using (StreamWriter sWrite = File.CreateText(FILE_NAME)) { sWrite.Write(sb.ToString().Replace("encoding=\"utf-16\"", "encoding=\"utf-8\"").Replace("<urlList>", "").Replace("</urlList>", "").Replace("<dataList>", "").Replace("</dataList>", "").Replace("<displayList>", "").Replace("<displayList>", "").Replace("</displayList>", "")); sWrite.Close(); } //输出序列化后xml文件 Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "application/xml"; Response.WriteFile(HttpContext.Current.Server.MapPath("test.xml")); Response.Flush(); Response.Close(); Response.Write("生成成功!"); } catch (Exception ex) { Response.Write(ex.Message); } finally { } } catch (Exception ex) { Response.Write("错误!" + ex.Message); } }
/// <summary> /// Return the zero-based index of the first occurrence of a specific value /// in this urlCollection /// </summary> /// <param name="value"> /// The url value to locate in the urlCollection. /// </param> /// <returns> /// The zero-based index of the first occurrence of the _ELEMENT value if found; /// -1 otherwise. /// </returns> public virtual int IndexOf(url value) { return this.List.IndexOf(value); }
var(url, fileName) = post;
/// <summary> /// Removes the first occurrence of a specific url from this urlCollection. /// </summary> /// <param name="value"> /// The url value to remove from this urlCollection. /// </param> public virtual void Remove(url value) { this.List.Remove(value); }
/// <summary> /// Main method. /// </summary> /// <param name="args">Arguments</param> static void Main(string[] args) { SortedDictionary <string, HelpEntity> topicsAndAnchors = HelpContentCreator.CreateListOfTopics("z:/trunk/PR34-Documentation/PR26-DataPorter_Help.shfbproj"); SortedDictionary <string, TopicNode> dictionaryOfTopics = new SortedDictionary <string, TopicNode>(); Topic topic; TopicNode node; foreach (HelpEntity he in topicsAndAnchors.Values) { topic = he as Topic; node = new TopicNode(); node.Title = topic.TopicsTitle.Replace(" ", ""); node.Url = "html/" + topic.TopicsGuid.ToString() + ".htm"; if (!dictionaryOfTopics.ContainsKey(node.Title)) { dictionaryOfTopics.Add(node.Title, node); } foreach (string anchor in topic.Anchors) { node = new TopicNode(); node.Title = anchor.Replace(" ", ""); node.Url = "html/" + topic.TopicsGuid.ToString() + ".htm#" + anchor; if (!dictionaryOfTopics.ContainsKey(node.Title)) { dictionaryOfTopics.Add(node.Title, node); } } } Topics tpcs = new Topics(dictionaryOfTopics); FileInfo topicsFile = new FileInfo(Properties.Settings.Default.HelpDocumentationAllTopics); tpcs.WriteToXML(topicsFile); SortedDictionary <string, url> dictionaryOfUrl = new SortedDictionary <string, url>(); url url; //Topic topic; string topicTitle; url = new url(); url.loc = "http://www.commsvr.com/UAModelDesigner/Index.aspx"; url.priority = (decimal)1; url.prioritySpecified = true; url.changefreq = changefreq.monthly; url.changefreqSpecified = true; url.lastmod = System.DateTime.Now.Date.ToString(); dictionaryOfUrl.Add("RootElement", url); foreach (HelpEntity he in topicsAndAnchors.Values) { topic = he as Topic; url = new url(); topicTitle = topic.TopicsTitle.Replace(" ", ""); url.loc = "http://www.commsvr.com/UAModelDesigner/Index.aspx" + "?topic=" + "html/" + topic.TopicsGuid.ToString() + ".htm"; url.priority = (decimal)0.8; url.prioritySpecified = true; url.changefreq = changefreq.monthly; url.changefreqSpecified = true; url.lastmod = System.DateTime.Now.Date.ToString(); if (!dictionaryOfUrl.ContainsKey(topicTitle)) { dictionaryOfUrl.Add(topicTitle, url); } } urlset urlSet = new urlset(dictionaryOfUrl); FileInfo siteMapFile = new FileInfo("z:/trunk/PR34-Documentation" + "/" + "sitMap.xml"); urlSet.WriteToXML(siteMapFile); }
_client = new Lazy <HttpClient>(() => CreateClient(url, username, password));
/// <summary> /// Determines whether a specfic url value is in this urlCollection. /// </summary> /// <param name="value"> /// The url value to locate in this urlCollection. /// </param> /// <returns> /// true if value is found in this urlCollection; /// false otherwise. /// </returns> public virtual bool Contains(url value) { return(this.List.Contains(value)); }
return(RequestAsync(url, parameters, GET));
static void crawl(SqlConnection connImport01, string contratto, dbparams tip) { try { ArrayList urls = new ArrayList(); foreach (string siglaProvincia in province) { string categoria = ""; switch (tip.idcategoria) { case 1: categoria = “xxxx”; break; case 2: categoria = “xxxx”; break; } url uIT = new url(); uIT.uri = string.Format(“xxxxxxxxxxxxxxxxxxx”, contratto, categoria, tip.tipologia, siglaProvincia.ToLower() ); uIT.siglaprovincia = siglaProvincia; urls.Add(uIT); } for (int u = 0; u < urls.Count; u++) { ForUrls: url uu = (url)urls[u]; logger.Info(uu.uri); string baseUrl = uu.uri; HtmlDocument basedom = new HtmlDocument(); basedom = Functions.GetHtmlDocumentByUrl(baseUrl, logger); string baseHtml = basedom.DocumentNode.InnerHtml; HtmlNode content = basedom.GetElementbyId("results"); if (content != null) { string pagination_results = Functions.extractFirstOccur(content.InnerHtml, " di * xxxx”); if (pagination_results.IsNumeric() && pagination_results.Trim() != "0") { string limit = pagination_results; limit = limit.Replace(".", ""); if (Functions.IsNumeric(limit)) { int numPages = Convert.ToInt32(limit) / resultsPerPage; if (numPages * resultsPerPage < Convert.ToInt32(limit)) { numPages += 1; } for (int x = 1; x <= numPages; x++) { try { Console.WriteLine("Pagina " + x.ToString()); HtmlDocument pagedom = new HtmlDocument(); if (x > 1) { pagedom = Functions.GetHtmlDocumentByUrl(baseUrl.Replace("lista-1", "lista-" + x.ToString()), logger); } else { pagedom = basedom; } HtmlNode searchResults = pagedom.GetElementbyId("searchResultsTbl"); if (searchResults != null) { ArrayList results = Functions.getElementsByClass(searchResults, "resultBody first tier1", "resultBody tier1"); foreach (HtmlNode hn in results) { try { bool nuovoAnnuncio = hn.InnerHtml.Contains("<div class=\"newIcon\"></div>"); if (!nuovoAnnuncio) { u++; if (u == urls.Count) { return; } else { goto ForUrls; } } if (nuovoAnnuncio) { adResult ad = new adResult(); ad.idtipologia = tip.idtipologia; ad.idcategoria = tip.idcategoria; ad.url = Functions.extractFirstOccur(hn.InnerHtml, "href=\"*\""); ad.id = hn.Id.Replace("t", ""); string city = Functions.retrieveStringAfterChars(ad.url, tip.tipologia + "-" + uu.siglaprovincia.ToLower() + "-"); city = Functions.retrieveStringBeforeChars(city, "-"); city = city.Replace("+", " "); if (ad.url != "") { ad.url = ConfigurationManager.AppSettings["urlPortale"] + ad.url; } string imgSrc = Functions.extractFirstOccur(hn.InnerHtml, "data-src='*'"); if (imgSrc.Contains("placeholder.jpg")) { imgSrc = ""; } ad.imgSrc = imgSrc; ad.date = DateTime.Now; comune comuneByName = getComuneByName(connImport01, city); if (comuneByName != null) { ad.idcomune = comuneByName.IDComune.ToString(); ad.city = comuneByName.Comune; } if (ad.idcomune != "" && ad.idcomune != null) { string zone = Functions.extractFirstOccur(hn.InnerHtml, "<p class=\"zone\">*</p>"); if (comuniConQuartieri.Contains(city)) { quartiereportale qp = getQuartierePortaleByName(connImport01, comuneByName.IDComune, zone); if (qp != null) { ad.idquartiere = qp.idquartiere; ad.idquartiereportale = qp.nrtavola; } } else { ad.idquartiereportale = 0; ad.idquartiere = 0; } ad.zona = zone; HtmlDocument basedomScheda = new HtmlDocument(); basedomScheda = Functions.GetHtmlDocumentByUrl(ad.url, logger); string htmlScheda = basedomScheda.DocumentNode.InnerHtml; ad.title = Functions.extractFirstOccur(htmlScheda, "<title>*-", "", true); Console.WriteLine(ad.id + " - " + ad.city + " - " + ad.title); string pr = Functions.extractFirstOccur(htmlScheda, "class=\"price\"><span class=\"hidden\">€ *</span>", "", true).Replace(".", ""); if (Functions.IsNumeric(pr)) { ad.price = Convert.ToDecimal(pr); } else { ad.price = 0; } string description = Functions.extractFirstOccur(htmlScheda, "<p class=\"body\">*</p>"); if (description != "") { ad.title = description; } if (ad.title.Length > 2000) { ad.title = ad.title.Substring(0, 1997) + "..."; } ad.idtipologia = disambiguateTipologia(ad, tip); string mq = Functions.extractFirstOccur(htmlScheda, "<li>Metri quadri:<span>* mq</span></li>"); string locali = Functions.extractFirstOccur(htmlScheda, "<li>Locali:<span>*</span></li>"); if (Functions.IsNumeric(locali)) { ad.locali = Convert.ToInt32(locali); } else { ad.locali = 0; } if (Functions.IsNumeric(mq)) { ad.mq = Convert.ToInt32(mq); } else { ad.mq = 0; } ad.contratto = contratto.Substring(0, 1).ToUpper(); saveAd(connImport01, ad); } } } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error("Errore", ex); esitoErrors += 1; esitoErrorsNotes += "\r\n" + ex.Message; } } } } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error("Errore", ex); esitoErrors += 1; esitoErrorsNotes += "\r\n" + ex.Message; } } } } } } } catch (Exception ex) { Console.WriteLine(ex.Message); logger.Error("Errore", ex); esitoErrors += 1; esitoErrorsNotes += "\r\n" + ex.Message; } }
/// <summary> /// Return the zero-based index of the first occurrence of a specific value /// in this urlCollection /// </summary> /// <param name="value"> /// The url value to locate in the urlCollection. /// </param> /// <returns> /// The zero-based index of the first occurrence of the _ELEMENT value if found; /// -1 otherwise. /// </returns> public virtual int IndexOf(url value) { return(this.List.IndexOf(value)); }
public static implicit operator Url([NotNull] string url) => new Url(url);
var response = await Post(url, args);