Login

konkr.com API detect is spam - lastest

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

import os, json, simplejson, datetime, time, urllib, urllib2
from socket import gethostname, gethostbyname

class MiniAkismet:
    def __init__(self, akk=None, aip=None, con=None, usa=None):
    	self.api_konkr_key = akk
    	self.author_ip = aip
    	self.content = con
    	self.user_agent = usa

    def submit_data(self):
		try:
			url = "http://%s.api.konkr.com/isspam" % (self.api_konkr_key)
			headers = {'User-Agent' : self.user_agent}      
			data = {'author_ip': self.author_ip, 'content': self.content}
			data_encode = urllib.urlencode(data)
			req = urllib2.Request(url, data_encode, headers)		
			h = urllib2.urlopen(req)
			resp = h.read()
			msg = resp     
		except: 
			msg = 'Error detect spam'

		print msg

api_konkr_key = '1eee28f67868'
author_ip = gethostbyname(gethostname())
spam = 'Sex viagra porn Sarkozy clocking and enlarge your very little penis'
ham = 'konkr/alpha by Toorop with Protecmail.com, le must du filtrage des spams pour blog et pour email'
user_agent = "Mozilla/5.0 (X11; U; Linux i686) Gecko/20071127 Firefox/2.0.0.11"  

submit = MiniAkismet(api_konkr_key, author_ip, ham, user_agent)
if submit.submit_data():
	print 'End ham submit'

More like this

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

Comments

Please login first before commenting.