Hack Forums
[.NET] (vb.net source) Extracting all bad words from "noswearing.com" - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] (vb.net source) Extracting all bad words from "noswearing.com" (/showthread.php?tid=2631486)



(vb.net source) Extracting all bad words from "noswearing.com" - nathan72389 - Jun 29, 2012

I was writing this irc bot and wanted to give it a mean personality. after doing a bit of googling i found a site that listed alot of "bad words" but the problem was that they had it all separated through different pages. Rather than just copying and pasting everything into notepad and then removing dead lines and useless text, i decided to make this little app and just have it do all the work for me.

[img]http://i.minus.com/irzNS13thlSPc.png[/img]

all i needed the app to do was get the bad words and then print them to a file, one word per line. easy.

here is the code incase anyone wants to use any of it.

Code
Imports System.Net
Imports System.IO
Imports System.Text.RegularExpressions

Module Module1

    Sub Main()
  Dim count As Integer
  Dim Source As String
  Dim Wc As New WebClient
  Dim dir As String = Process.GetCurrentProcess.MainModule.FileName
  dir = dir.Remove(dir.LastIndexOf("\") + 1, (dir.Length - dir.LastIndexOf("\") - 1))
  If File.Exists(dir & "output.txt") Then File.Delete(dir & "output.txt")
  For i As Integer = 65 To 90
    Source = Wc.DownloadString("http://www.noswearing.com/dictionary/" & Chr(i))
    For Each line As Match In MatchAll(Source, "valign=top>", "\n")
    For Each badword As Match In MatchAll(line.Value, "name=" & Chr(34), Chr(34))
    Console.WriteLine(badword.Value)
    File.AppendAllText(dir & "output.txt", badword.Value & vbCrLf)
    count += 1
    Next
    Next
  Next
  Console.WriteLine(count & " words added.")
  Console.WriteLine("Press Enter to continue...")
  Console.ReadLine()
    End Sub

    Function MatchAll(ByVal SourceString As String, ByVal strStart As String, ByVal strEnd As String) As MatchCollection
  Return Regex.Matches(SourceString, "(?<=" & strStart & ").*?(?=" & strEnd & ")")
    End Function

End Module

all of the code should be pretty easy to understand.

so, there ya have it, if you have any questions, feel free to ask.


* - marvinn - Jun 29, 2012

uuuhm.

Code
dir = dir.Remove(dir.LastIndexOf("\") + 1, (dir.Length - dir.LastIndexOf("\") - 1))

Code
dir = Path.GetPathRoot(dir)

A bit cleaner?;x


* - smileynigga - Jun 29, 2012

lool rofl rifk n00b h3h3 t3st som3thing :P


* - Fat Tony - Jun 29, 2012

Don't really see the point of this but good luck...


* - polas6 - Apr 13, 2015

Hi,guys

i have button 'to remove bad words from listbox
textbox to find words i want and listbox.

Can you tell me how to do that in listbox and save it to txt good words without savefiledialog popup ?

I have loaded 200 urls in listbox and i want to remove useless words from listbox and save them to desktop but only good.

I need full Example of code:

Code
if <words> <are bads of urls> then
    'dont add it to listbox
else
    'add it to lisbox
end if
'loop faster.

How to do that ?

Thanks.


* - EagleEye - Apr 13, 2015

lollllll why should we back in time to
06-29-2012

btw that site for bad words not for good words so .... idk know what r u trying to make good word list :/


* - CodeAssassin - Apr 13, 2015

Shit actually had me thinking Nathan finally started releasing again, rather then just trolls.....

Seems someone likes to go grave digging LOL.


* - SIM-1984933 - Apr 13, 2015

How....grotesque.
a website of the sort is a bit outlandish don't you think?


* - SIM-1676753 - Apr 13, 2015

Holy mother of gravedig. Quit that shit nigga.