Login

konkr.com API detect is spam

Author:
magik_cypress
Posted:
November 25, 2011
Language:
Python
Version:
1.3
Score:
0 (after 0 ratings)

Detect Spam or Ham with a konkr web-service

https://konkr.com/api-documentation

 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
#! /usr/bin/python2.6

import json, simplejson, datetime, time, urllib2

def get_content():
	try:
		url = "http://en.lipsum.com/feed/json?amount=1"
		file = urllib2.urlopen(url)
		content = file.read()
		if content is not None:  
			json = simplejson.loads(content)
			out = json['feed']['lipsum']
	except: 
		out = 'Error content'
	return out	

def main(CONTENT):
    try:
        url = "http://%s.api.konkr.com/isspam?author_ip='%s'&content='%s'" % (API_KONKR_KEY, AUTHOR, CONTENT)
        file = urllib2.urlopen(url)
        data = file.read()
        if data:
			json = simplejson.loads(data)              
			msg = json['success']
    except: 
        msg = 'Error detect spam'

    print msg

if __name__ == "__main__":
	API_KONKR_KEY = 'your_key'
	AUTHOR = '127.0.0.1'
	SPAM = 'Sex viagra porn Sarkozy clocking and enlarge your very little penis'
	HAM = get_content()

	print 'Detect ham'
	main(HAM)  
	print 'Detect spam'
	main(SPAM) 

More like this

  1. Template tag - list punctuation for a list of items by shapiromatron 10 months, 4 weeks ago
  2. JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 11 months ago
  3. Serializer factory with Django Rest Framework by julio 1 year, 5 months ago
  4. Image compression before saving the new model / work with JPG, PNG by Schleidens 1 year, 6 months ago
  5. Help text hyperlinks by sa2812 1 year, 7 months ago

Comments

Please login first before commenting.