Skip to content

Commit

Permalink
chromedriver and screenshot timeout.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeumus committed Jul 15, 2015
1 parent 84f77b6 commit 9b57c92
Show file tree
Hide file tree
Showing 74 changed files with 27 additions and 5 deletions.
Binary file added chromedriver
Binary file not shown.
8 changes: 8 additions & 0 deletions notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ Postgres in Cloud 9:
- `sudo -s` then `sudo -u postgres psql`
- createuser -d -P -s pixm
- createdb -O mike phishingdb

Install psycopg2 for postgres
- http://stackoverflow.com/a/5450183
- `sudo apt-get install libpq-dev python-dev`
- `sudo apt-get install psycopg2`

Using chromedriver
- http://selenium-python.readthedocs.org/en/latest/faq.html#how-to-use-chromedriver
Binary file removed scrapy_phishtank/phishots/AOL_3309944_screenshot.png
Binary file not shown.
Binary file not shown.
Binary file removed scrapy_phishtank/phishots/AOL_3309973_screenshot.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed scrapy_phishtank/phishots/AOL_3309987_screenshot.png
Binary file not shown.
Binary file removed scrapy_phishtank/phishots/AOL_3310026_screenshot.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed scrapy_phishtank/phishots/AOL_3310097_screenshot.png
Binary file not shown.
Binary file removed scrapy_phishtank/phishots/AOL_3310111_screenshot.png
Binary file not shown.
Binary file removed scrapy_phishtank/phishots/AOL_3310112_screenshot.png
Binary file not shown.
Binary file removed scrapy_phishtank/phishots/AOL_3310319_screenshot.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed scrapy_phishtank/phishots/AOL_3310347_screenshot.png
Binary file not shown.
Binary file removed scrapy_phishtank/phishots/AOL_3310348_screenshot.png
Binary file not shown.
Binary file not shown.
Binary file removed scrapy_phishtank/phishots/AOL_3310350_screenshot.png
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
24 changes: 19 additions & 5 deletions scrapy_phishtank/pishing/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# Phishtank API key: http://data.phishtank.com/data/{}/online-valid.json.bz2'.format(PHISHTANK_API_KEY)
url = 'http://data.phishtank.com/data/{}/online-valid.json'.format(PHISHTANK_API_KEY)


@shared_task(name="StorePhishURL")
def StorePhishURL():
r = requests.get(url)
Expand All @@ -34,27 +33,42 @@ def StorePhishURL():
if created:
# freshphish.fresh_id = threat['phish_id']
freshphish.fresh_target = threat['target']

try:
# take screenshot if status code is good
if r.status_code != requests.codes.ok:
return "Error: Unexpected response {}".format(r)
# take screenshot of fresh_url
driver = webdriver.Firefox()
#driver = webdriver.Firefox()
#executable_path="/usr/bin/chromedriver"
driver = webdriver.Chrome()
# we dont have driver_arguments varialble!!!
# selenium just uses the webdriver APIs so why could we use driver_arguments ?
# python will raise an error asking where did you come with that varialble XD
# I see. but.. I bet it's posible somehow lol
# lol coding is so logical not feeling XD
# :p
# lets try ipython and we call selenium inside of it and th chromderiver too
# good idea, why isn't ipython my default when I do `./manage.py shell` on this tower?
# becasue you dont have ipython and it runs python interprester :D
# :p

#driver_arguments['chrome_options'].add_argument('--no-sandbox')
deriver.set_page_load_timeout(30)
driver.get(threat['url'])
# save "phishshots" (screenshots) in folder http://stackoverflow.com/questions/27874002/python-selenium-save-screenshot-in-newly-created-folder
driver.save_screenshot('phishots/{0}_{1}_screenshot.png'.format(threat['target'], threat['phish_id']))
driver.quit()
except requests.exceptions.RequestException as e:
# A serious problem happened, like an SSLError or InvalidURL
return "Error: {}".format(e)

if threat['online'] == 'yes':
freshphish.live_phish = True # u'online': u'yes'
# Consider any status other than 2xx an error
else:
freshphish.live_phish = False

freshphish.verification_time = threat['verification_time']
if threat['details']:
freshphish.country = threat['details'][0]['country']
Expand Down

0 comments on commit 9b57c92

Please sign in to comment.