Skip to content

Commit

Permalink
Merge pull request 1tayH#2 from cclauss/patch-1
Browse files Browse the repository at this point in the history
Circle CI: Run tests on both Python 2.7 and 3.6
  • Loading branch information
1tayH authored Jul 2, 2018
2 parents 4ff350a + 650f5e4 commit 8f4e365
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 18 deletions.
18 changes: 15 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
version: 2
jobs:
build:
Python_2.7:
docker:
# specify the version you desire here
# use `-browsers` prefix for selenium tests, e.g. `3.6.1-browsers`
- image: circleci/python:2.7

working_directory: ~/repo

steps:
steps: &steps
- checkout

# Download and cache dependencies
Expand Down Expand Up @@ -41,4 +41,16 @@ jobs:
- store_artifacts:
path: test-reports
destination: test-reports


Python_3.6:
docker:
- image: circleci/python:3.6
working_directory: ~/repo
steps: *steps

workflows:
version: 2
build:
jobs:
- Python_2.7
- Python_3.6
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

A simple python script that generates random HTTP/DNS traffic noise in the background while you go about your regular web browsing, to make your web traffic data less valuable for selling and for extra obscurity.

Tested on MacOS High Sierra, Ubuntu 16.04 and Raspbian Stretch
Tested on MacOS High Sierra, Ubuntu 16.04 and Raspbian Stretch and is compatable with both Python 2.7 and 3.6

## Getting Started

Expand Down Expand Up @@ -103,4 +103,4 @@ This project is licensed under the GNU GPLv3 License - see the [LICENSE.md](LICE
## Acknowledgments
This project has been inspired by
* [RandomNoise](http://www.randomnoise.us)
* [web-traffic-generator](https://github.com/ecapuano/web-traffic-generator)
* [web-traffic-generator](https://github.com/ecapuano/web-traffic-generator)
33 changes: 20 additions & 13 deletions noisy.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import requests
import re
import time
import random
import logging
import argparse
import datetime
import json
import urlparse
import logging
import random
import re
import sys
import datetime
import time

import requests

try: # Python 2
from urllib.parse import urljoin, urlparse
except ImportError: # Python 3
from urlparse import urljoin, urlparse

reload(sys)
sys.setdefaultencoding('latin-1')
try: # Python 2
reload(sys)
sys.setdefaultencoding('latin-1')
except NameError: # Python 3
pass


class Crawler(object):
Expand Down Expand Up @@ -52,16 +59,16 @@ def _normalize_link(link, root_url):
:param root_url: the URL the DOM was loaded from
:return: absolute link
"""
parsed_url = urlparse.urlparse(link)
parsed_root_url = urlparse.urlparse(root_url)
parsed_url = urlparse(link)
parsed_root_url = urlparse(root_url)

# '//' means keep the current protocol used to access this URL
if link.startswith("//"):
return "{}://{}{}".format(parsed_root_url.scheme, parsed_url.netloc, parsed_url.path)

# possibly a relative path
if not parsed_url.scheme:
return urlparse.urljoin(root_url, link)
return urljoin(root_url, link)

return link

Expand Down Expand Up @@ -111,7 +118,7 @@ def _extract_urls(self, body, root_url):
urls = re.findall(pattern, str(body))

normalize_urls = [self._normalize_link(url, root_url) for url in urls]
filtered_urls = filter(self._should_accept_url, normalize_urls)
filtered_urls = list(filter(self._should_accept_url, normalize_urls))

return filtered_urls

Expand Down

0 comments on commit 8f4e365

Please sign in to comment.