Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.