Skip to content

Instantly share code, notes, and snippets.

@iMilnb
Created August 28, 2015 00:01
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save iMilnb/75d65d88ce649b1f191a to your computer and use it in GitHub Desktop.
Automatic SpamCop report validation with python mechanize
import mechanize
br = mechanize.Browser()
br.set_handle_robots(False)
br.open("http://www.spamcop.net/")
br.select_form(nr=0)
br.form['username']='your@spamcop.registered.email'
br.form['password']='yourSpamCopPassword'
br.submit()
has_report = True
while has_report is True:
try:
l = br.click_link(text='Report Now')
except:
has_report = False
print('No report found.')
break
br.open(l)
try:
br.select_form(name='sendreport')
except:
continue
print('Sending report for {0}'.format(br.form['reports']))
# the following will possibly fill br with a new 'Report Now' link
br.submit(label='Send Spam Report(s) Now')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment