Created
August 28, 2015 00:01
-
-
Save iMilnb/75d65d88ce649b1f191a to your computer and use it in GitHub Desktop.
Automatic SpamCop report validation with python mechanize
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mechanize | |
br = mechanize.Browser() | |
br.set_handle_robots(False) | |
br.open("http://www.spamcop.net/") | |
br.select_form(nr=0) | |
br.form['username']='[email protected]' | |
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