-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
98 additions
and
25 deletions.
There are no files selected for viewing
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
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
Empty file.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import requests | ||
import re | ||
from tqdm import tqdm | ||
from begoneads.collectors.base_collector import BaseCollector | ||
|
||
|
||
class LocalCollector(BaseCollector): | ||
"""A class that collects local host files | ||
Attributes: | ||
sources: list | ||
""" | ||
|
||
def try_get_sources(self, sources): | ||
"""Try and get each file""" | ||
|
||
filtered = [] | ||
|
||
for source in tqdm(sources): | ||
with open(source) as _file: | ||
filtered.append(_file.read()) | ||
|
||
return filtered |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import requests | ||
import re | ||
from tqdm import tqdm | ||
from begoneads.collectors.base_collector import BaseCollector | ||
|
||
|
||
class RemoteCollector(BaseCollector): | ||
"""A class that collects the remote host files | ||
Attributes: | ||
sources: list | ||
""" | ||
|
||
def try_get_sources(self, sources): | ||
"""Try and get each source, don't return them if the request was not succesful""" | ||
|
||
filtered = [] | ||
|
||
for source in tqdm(sources): | ||
response = requests.get(source) | ||
|
||
if response.status_code >= 200 and response.status_code < 300: | ||
content = str(response.text) | ||
|
||
filtered.append(content) | ||
|
||
return filtered |
4 changes: 2 additions & 2 deletions
4
begoneads/collector_test.py → ...neads/collectors/remote_collector_test.py
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
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
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