summaryrefslogtreecommitdiff
path: root/scratch.rb
blob: b725a5a807fe018e686577613e1ddf6d2fb1fab3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-

load 'mwapi.rb'
require 'yaml'

mw = MWApi.new('https://wiki.parabolagnulinux.org/api.php')
credentials = YAML.load_file('credentials.yml')
mw.login(credentials['username'], credentials['password'])

@keywords=[
	# brand names
	/(Crimson|Pink|Purple|Green|Orange) Dye/i,
	/Air Jordan/i,
	/Andrew Ting/i,
	/Beats by Dre/i,
	/Braun 5270/i,
	/Buccaneers/i,
	/Canada Goose/i,
	/Club Penguin/i,
	/Diablo 3/i,
	/Doudoune/i,
	/Focus T25/i,
	/Gamma Blue/i,
	/Google Pagerank/i,
	/Jeffraham/i,
	/Jillian Michaels/i,
	/Jordan Fusion/i,
	/Jordan Retro/i,
	/Kate Spade/i,
	/Michael[ _]Kors/i,
	/\b(NBA|NFL)\b/i,
	/\b(world|globe|planet) cup\b/i,
	/\b49ers\b/i,
	/\bCisco 200-120\b/i,
	/\bDr\.? Dre\b/i,
	/\bGucci\b/i,
	/\bNike\b/i
	/\bretro 11 /i,
	/\buggs?\b/i,
	/officialnflprostore/i,
	# script kiddie topics
	/ on Hack Wi-Fi$/i,
	/Cracked Steam/i,
	/Psn code generator/i,
	/Steam Key Generator/i,
	/\bpc games? (free|crack)/i,
	/crack pc/i,
	# health topics
	/(body|excess) weight/i,
	/Arrhythmia/i,
	/Cardiovascular/,
	/Garcinia/i,
	/P90X/,
	/Resistance Band/i,
	/\bbodybuilding\b/i,
	/\bhypertension\b/i,
	/\bmuscle\b/i,
	/\bstairlifts?\b/i,
	/\bvegan\b/i,
	/diabetes/i,
	/dr oz/i,
	/elliptical (equipment|machines?)/i,
	/fat (burning|loss)/i,
	/health care/i,
	/heart (disease|attack)/i,
	/hemorrhoids/i,
	/herbalife/i,
	/more wellness/i,
	/pilates/i,
	/prescription/i,
	/skin care/i,
	/weight[ -](loss|reduction)/i,
	# sex topics
	/\b(male|breast) enhancement\b/i,
	/\b(sex|adult) cam/i,
	/\b(ejaculation|lesbian|penis|viagra)\b/i,
	# consumer topics
	/Possum (Removalist|Infestation)/i,
	/\b(coffee|tea) extract\b/i,
	/\b(green|ginseng) (coffee|tea)\b/i,
	/\bbaby shower\b/i,
	/\bdiy l[ue]x[ue]ry\b/i,
	/\bgreen pan\b/i,
	/\bipage (web)?host/i,
	/\bjerseys?\b/i,
	/\bmen.?s (fashion|casual wear|health)\b/i,
	/\brap beats\b/i,
	/\breal estate\b/i,
	/\bsearch engine (marketing|optimization)\b/i,
	/\bvigorous motivators\b/i,
	/apartment moves/i,
	/auto insurance/i,
	/furniture removal/i,
	/goji berr(ies|y)/i,
	/jewellery/i,
	# internet topics
	/Twitter follower/i,
	/\b(good|quality) social media\b/i,
	/\bclick here\b/i,
	/\bsocial media strategy\b/i,
	/affiliate advertising/i,
	/pay[ -]per[ -]click/i
	# formats
	/^(aid|assist) on (where|the place)/i,
	/^A Background In/i,
	/^An? ( (simple|informative))? analysis of /i,
	/1st Impressions in/i,
	/The (Selection|Choice|Decision) of the .* Is Your/i,
	# unsorted
	/\b(chinchilla|shit|marketing|finance|footwear|shoes|islamist|wholesale|sherbet|bankrupt|outfits|casinos?|surcharges?)\b/i,
	/(Plombier|Serrurier) paris/i,
	/\bcash (online|loan)/i,
	/\bcredit (card|check|repair)\b/i,
]

def kw(title)
	@keywords.each do |re|
		if re =~ title
			return true
		end
	end
	return false
end

apcontinue = ''
while not apcontinue.nil? do
	print "Searching...\n"
	data = mw.query(:list => :allpages, :aplimit => 200, :apcontinue => apcontinue)
	titles = data['query']['allpages'].select{|page| kw(page['title']) }.map{|page| page['title']}
	print "Deleting #{titles.length} articles...\n"
	if (titles.length > 0)
		mw.delete_by_title(titles, { :reason => 'Spam' })
	end
	if data['query-continue'].nil?
		apcontinue = nil
	else
		apcontinue = data['query-continue']['allpages']['apcontinue']
	end
	print "apcontinue = #{apcontinue.inspect}\n"
end