469,286 Members | 2,522 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,286 developers. It's quick & easy.

Python Comparing Strings Help

Hello... This is my first time posting. One of my co workers told me this is the place to be for help on these kinds of situations. Anyhow this is what I got:

I am trying to make a simple anti phishing script in python. I need help figuring how to look at a simple html source statement such as this (below)and then have the program spit back "bad news" or so forth.

<a href="http://bogus.com" >https://mybank.com</a>

Expand|Select|Wrap|Line Numbers
  1. #! /usr/bin/python
  2. # scan.py
  3. import sys,string,re
  4. f = open(sys.argv[1])
  5. lines = f.readlines()
  6. string = string.join(lines,"")
  7. # I or IGNORECASE for case insensitive, S or DOTALL for . matches \n
  8. phmatch = re.search(r'(secure).*?(phishing)',string,re.IGNORECASE | re.DOTALL)
  9. if phmatch:
  10.   print "Looks like a phishing scam."
  11.   print "Redirection from %s to %s." % (phmatch.group(1),phmatch.group(2))
  12. else:
  13.   print "Looks Ok."
Apr 11 '06 #1
0 3508

Post your reply

Sign in to post your reply or Sign up for a free account.

By using this site, you agree to our Privacy Policy and Terms of Use.