public LvProxyItem(NameIdentifiedInfo nii) { ProxyInfo pi = (ProxyInfo)(nii); this.profileName = pi.name; this.ip = pi.ip; this.username = pi.username; }
private void butProxyEdit_Click(object sender, RoutedEventArgs e) { LvProxyItem lvi = ((LvProxyItem)lvProxy.SelectedItem); if (lvi != null) { ProxyInfo pi = (ProxyInfo)infoManager.GetProxyByName(lvi.profileName); tbProxyName.Text = pi.name; tbProxyIpAddress.Text = pi.ip; tbProxyPassword.Text = pi.password; tbProxyUsername.Text = pi.username; } }
public static void setProxy(ProxyInfo proxyInfo, HttpWebRequest req) { ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; req.UserAgent = userAgent; if (proxyInfo != null) { WebProxy proxy = new WebProxy(); proxy.Address = new Uri(proxyInfo.ip); proxy.Credentials = new NetworkCredential(proxyInfo.username, proxyInfo.password); req.Proxy = proxy; } else { req.Proxy = null; } }
// Gets page HTML as String // gets it no matter what. public static string GetPageHTML(string uri, CookieContainer cookies, ProxyInfo proxyInfo) { ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uri); req.UserAgent = userAgent; req.Method = "GET"; req.CookieContainer = cookies; setProxy(proxyInfo, req); string pageHTML = ""; var res = SendRequestAtAllCosts(req); var responseReader = new StreamReader(res.GetResponseStream()); pageHTML = responseReader.ReadToEnd(); responseReader.Close(); return(pageHTML); }
private void butProxyAdd_Click(object sender, RoutedEventArgs e) { ProxyInfo pi = new ProxyInfo(); pi.name = tbProxyName.Text; pi.ip = tbProxyIpAddress.Text; pi.username = tbProxyUsername.Text; pi.password = tbProxyPassword.Text; if (pi.ip != "") { if (!pi.ip.Contains("http")) { pi.ip = "http://" + pi.ip; } } infoManager.addProxy(pi); infoManager.updateProxiesList(); infoManager.saveProxiesList(); }
public List <ShopItemInfo> GetItemsFromCategory(string category, CookieContainer cookies, ProxyInfo proxyInfo) { string categoryURL = "http://www.supremenewyork.com/shop/all/" + category; string pageHTML = WebTools.GetPageHTML(categoryURL, cookies, proxyInfo).ToLower(); //<a class="name-link" href="/shop/sweatshirts/w1lxfbkgv/inh4q21pg">Split Crewneck Sweatshirt</a></h1> //<p><a class="name-link" href="/shop/sweatshirts/w1lxfbkgv/inh4q21pg">Brown</a> string RegExString = "<a class=\"name-link\" href=\"(/[- / a-z 0-9 _]*)\">(.*?)</a></h1>"; RegExString += "<p><a class=\"name-link\" href=\"[- / a-z 0-9 _]*\">(.*?)</a>"; Regex regExpPattern = new Regex(RegExString); MatchCollection allMatches = regExpPattern.Matches(pageHTML); List <ShopItemInfo> items = new List <ShopItemInfo>(); foreach (var match in allMatches) { Match m = (Match)match; //Console.WriteLine(m.Groups[1].ToString() + " " + m.Groups[2].ToString() + " " + m.Groups[3].ToString()); items.Add(new ShopItemInfo(m.Groups[1].ToString(), m.Groups[2].ToString(), m.Groups[3].ToString())); } return(items); }