Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to Python3 , Add Travis-CI #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
sudo: required
language: python

python:
- "2.7"
- "3.6"
- "3.7-dev" # 3.7 development branch

install:

script:
- "python setup.py install"
2 changes: 1 addition & 1 deletion concurrentfloodscraper/pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ def pop(self, amount=1):

# returns a string of some stats
def print_info(self):
print('PubSub: pushed=%s, popped=%s, current_size=%s' % (self.pushed, self.popped, len(self.queue)))
print(('PubSub: pushed=%s, popped=%s, current_size=%s' % (self.pushed, self.popped, len(self.queue))))
2 changes: 1 addition & 1 deletion concurrentfloodscraper/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def register(cls, regex):
# return the scraper class responsible for a given url
@staticmethod
def route(url):
for regex, cls in RouteManager.paths.items():
for regex, cls in list(RouteManager.paths.items()):
if regex.match(url):
return cls

Expand Down
6 changes: 3 additions & 3 deletions concurrentfloodscraper/scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ def __init__(self, url):

# main function. returns new_urls. any data is the responsibility of subclasses
def parse(self):
print('Parsing %s' % self.url)
print(('Parsing %s' % self.url))

# get text
try:
text = self.load_page()
except requests.exceptions.RequestException as e:
print('Error loading "%s". Error is %s' % (self.url, e))
print(('Error loading "%s". Error is %s' % (self.url, e)))
return [''] # no new urls

# subclass does their stuff
self.scrape_page(text)

# get new urls, and filter. return those to worker
all_urls = self.parse_all_urls(text)
new_urls = list(filter(lambda x: self.url_filter_regex.match(x), all_urls))
new_urls = list([x for x in all_urls if self.url_filter_regex.match(x)])
return new_urls

# get html code from url
Expand Down