Imports System.Net Imports System.Text.RegularExpressions Private Function GetBetween(ByVal Source As String, ByVal Str1 As String, ByVal Str2 As String, Optional ByVal Index As Integer = 0) As String Return Regex.Split(Regex.Split(Source, Str1)(Index + 1), Str2)(0) End Function
Try Dim r As HttpWebRequest = HttpWebRequest.Create("http://www.fakenamegenerator.com/") r.KeepAlive = True r.UserAgent = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36" Dim re As HttpWebResponse = r.GetResponse() Dim src As String = New System.IO.StreamReader(re.GetResponseStream()).ReadToEnd() Dim nameSpare As String = GetBetween(src, "<div class=""address"">", "</div>") Dim name As String = GetBetween(nameSpare, "<h3>", "</h3>") Dim address As String = GetBetween(nameSpare, "<div class=""adr"">", "</div>") address = address.Replace(" ", "") address = address.Replace("<br/>", ", ") address = address.Replace("</br>", ", ") Dim extraSpace As String = GetBetween(src, "<div class=""extra"">", "</div>") Dim phone As String = GetBetween(extraSpace, "<li class=""tel""><span class=""value"">", "</span></li>") Dim email As String = GetBetween(extraSpace, "<li class=""email""><span class=""value"">", "</span>") MsgBox(name & vbNewLine & address & vbNewLine & phone & vbNewLine & email) Catch ex As Exception MsgBox(ex.ToString()) End Try
Imports System.Net Imports System.Text.RegularExpressions Public Class Form1 Private Function GetBetween(ByVal Source As String, ByVal Str1 As String, ByVal Str2 As String, Optional ByVal Index As Integer = 0) As String Return Regex.Split(Regex.Split(Source, Str1)(Index + 1), Str2)(0) End Function Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Try Dim r As HttpWebRequest = HttpWebRequest.Create("http://www.fakenamegenerator.com/") r.KeepAlive = True r.UserAgent = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36" Dim re As HttpWebResponse = r.GetResponse() Dim src As String = New System.IO.StreamReader(re.GetResponseStream()).ReadToEnd() Dim nameSpare As String = GetBetween(src, "<div class=""address"">", "</div>") Dim name As String = GetBetween(nameSpare, "<h3>", "</h3>") Dim address As String = GetBetween(nameSpare, "<div class=""adr"">", "</div>") address = address.Replace(" ", "") address = address.Replace("<br/>", ", ") address = address.Replace("</br>", ", ") Dim extraSpace As String = GetBetween(src, "<div class=""extra"">", "</div>") Dim phone As String = GetBetween(extraSpace, "<li class=""tel""><span class=""value"">", "</span></li>") Dim email As String = GetBetween(extraSpace, "<li class=""email""><span class=""value"">", "</span>") MsgBox(name & vbNewLine & address & vbNewLine & phone & vbNewLine & email) Catch ex As Exception MsgBox(ex.ToString()) End Try End Sub End Class
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.