Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public string scrapefunction(string url,string search, string regexstring)
- {
- using (WebClient client = new WebClient()) // WebClient class inherits IDisposable
- {
- string allthreadusernames = "";
- string htmlCode = "";
- while (String.IsNullOrEmpty(htmlCode))
- {
- try
- {
- htmlCode = client.DownloadString(url);
- }
- catch
- {
- }
- }
- string[] htmlarray = htmlCode.Split(new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
- foreach (string line in htmlarray)
- {
- if (line.Contains(search))
- {
- var regex = new Regex(regexstring);
- var matches = regex.Matches(line);
- foreach (var singleuser in matches.Cast<Match>().ToList())
- {
- allthreadusernames = allthreadusernames + "\n" + singleuser.Groups[1].Value;
- }
- }
- }
- return allthreadusernames;
- }
Advertisement
Add Comment
Please, Sign In to add comment