-
Notifications
You must be signed in to change notification settings - Fork 19
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
4 changed files
with
37 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
# Copyright: (2013-2014) Michael Till Beck <[email protected]> | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright: (2013-2017) Michael Till Beck <[email protected]> | ||
# License: GPL-2.0+ | ||
|
||
#We collect xpath snippets at this place: <a href="https://github.com/Debianguru/MailWebsiteChanges/wiki/snippets">Snippet collection</a> - please feel free to add your own definitions! | ||
|
||
# We collect xpath snippets at this place: | ||
# <a href="https://github.com/Debianguru/MailWebsiteChanges/wiki/snippets">Snippet collection</a> | ||
# Feel free to contribute! | ||
|
||
|
||
from mwctools import URLReceiver as uri | ||
|
@@ -13,8 +18,6 @@ | |
from mwctools import Content | ||
from mwctools import Parser | ||
|
||
import os.path | ||
|
||
|
||
sites = [ | ||
|
||
|
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright: (2013-2015) Michael Till Beck <[email protected]> | ||
# Copyright: (2013-2017) Michael Till Beck <[email protected]> | ||
# License: GPL-2.0+ | ||
|
||
import io | ||
|
@@ -212,9 +212,9 @@ def pollWebsites(): | |
config = importlib.import_module(configMod) | ||
|
||
if dryrun: | ||
for site in config.sites: | ||
if site['name'] == dryrun: | ||
parseResult = runParsers(site['parsers']) | ||
for thesite in config.sites: | ||
if thesite['name'] == dryrun: | ||
parseResult = runParsers(thesite['parsers']) | ||
for p in parseResult: | ||
print(p.title) | ||
print(p.content) | ||
|
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 |
---|---|---|
@@ -1,35 +1,38 @@ | ||
#!/usr/bin/python3 | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright: (2013-2014) Michael Till Beck <[email protected]> | ||
# Copyright: (2013-2017) Michael Till Beck <[email protected]> | ||
# License: GPL-2.0+ | ||
|
||
|
||
import http.server | ||
import socketserver | ||
import importlib | ||
import sys | ||
import getopt | ||
|
||
|
||
bind = 'localhost' | ||
port = 8000 | ||
configMod = 'config' | ||
|
||
|
||
try: | ||
opts, args = getopt.getopt(sys.argv[1:], 'hc:b:p:', ['help', 'config=', 'bind=', 'port=']) | ||
opts, args = getopt.getopt(sys.argv[1:], 'hc:b:p:', ['help', 'config=', 'bind=', 'port=']) | ||
except getopt.GetoptError: | ||
print('Usage: FeedServer.py --config=config --port=8000') | ||
sys.exit(1) | ||
print('Usage: FeedServer.py --config=config --port=8000 --bind=localhost') | ||
sys.exit(1) | ||
|
||
for opt, arg in opts: | ||
if opt == '-h': | ||
print('Usage: FeedServer.py --config=config --bind=localhost --port=8000') | ||
exit() | ||
elif opt in ('-c', '--config'): | ||
configMod = arg | ||
elif opt in ('-b', '--bind'): | ||
bind = arg | ||
elif opt in ('-p', '--port'): | ||
port = int(arg) | ||
if opt == '-h': | ||
print('Usage: FeedServer.py --config=config --bind=localhost --port=8000') | ||
exit() | ||
elif opt in ('-c', '--config'): | ||
configMod = arg | ||
elif opt in ('-b', '--bind'): | ||
bind = arg | ||
elif opt in ('-p', '--port'): | ||
port = int(arg) | ||
|
||
config = importlib.import_module(configMod) | ||
|
||
|
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 |
---|---|---|
@@ -1,4 +1,12 @@ | ||
import urllib.request, urllib.error, urllib.parse | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright: (2013-2017) Michael Till Beck <[email protected]> | ||
# License: GPL-2.0+ | ||
|
||
|
||
import urllib.request | ||
import urllib.error | ||
import urllib.parse | ||
import subprocess | ||
|
||
|
@@ -23,13 +31,6 @@ class Receiver(Parser): | |
def __init__(self, uri): | ||
self.uri = uri | ||
|
||
def run(self): | ||
return super().run(contentList=[]) | ||
|
||
# output: [Content] | ||
def performAction(self): | ||
return self.performAction(contentList=[]) | ||
|
||
|
||
class Content: | ||
def __init__(self, uri, encoding, title, content, contenttype): | ||
|
@@ -129,7 +130,6 @@ def performAction(self, contentList): | |
result.extend(self.parseOneObject(content)) | ||
return result | ||
|
||
|
||
# input: Content, output: [Content] | ||
def parseOneObject(self, content): | ||
baseuri = content.uri | ||
|
@@ -201,15 +201,13 @@ def __init__(self, contentregex, titleregex=None): | |
self.contentregex = contentregex | ||
self.titleregex = titleregex | ||
|
||
|
||
# input: [Content], output: [Content] | ||
def performAction(self, contentList): | ||
result = [] | ||
for content in contentList: | ||
result.extend(self.parseOneObject(content)) | ||
return result | ||
|
||
|
||
# input: Content, output: [Content] | ||
def parseOneObject(self, content): | ||
contents = [] | ||
|