mirror of
https://github.com/wassname/FanFicFare.git
synced 2026-09-11 11:52:07 +08:00
Added adapter.py, now all working adapters must implement FanfictionSiteAdapter interface
This commit is contained in:
+30
@@ -0,0 +1,30 @@
|
||||
class FanfictionSiteAdapter:
|
||||
def __init__(self, url):
|
||||
pass
|
||||
|
||||
def requiresLogin(self, url = None):
|
||||
pass
|
||||
|
||||
def performLogin(self, url = None):
|
||||
pass
|
||||
|
||||
def extractIndividualUrls(self):
|
||||
pass
|
||||
|
||||
def getText(self, url):
|
||||
pass
|
||||
|
||||
def setLogin(self, login):
|
||||
pass
|
||||
|
||||
def setPassword(self, password):
|
||||
pass
|
||||
|
||||
def getStoryName(self):
|
||||
pass
|
||||
|
||||
def getAuthorName(self):
|
||||
pass
|
||||
|
||||
def getPrintableUrl(self, url):
|
||||
pass
|
||||
@@ -18,6 +18,7 @@ import BeautifulSoup as bs
|
||||
import htmlentitydefs as hdefs
|
||||
|
||||
from constants import *
|
||||
from adapter import *
|
||||
|
||||
try:
|
||||
import login_password
|
||||
@@ -25,7 +26,7 @@ except:
|
||||
# tough luck
|
||||
pass
|
||||
|
||||
class FFA:
|
||||
class FFA(FanfictionSiteAdapter):
|
||||
def __init__(self, url):
|
||||
self.url = url
|
||||
parsedUrl = up.urlparse(url)
|
||||
|
||||
@@ -18,6 +18,7 @@ import BeautifulSoup as bs
|
||||
import htmlentitydefs as hdefs
|
||||
|
||||
from constants import *
|
||||
from adapter import *
|
||||
|
||||
try:
|
||||
import login_password
|
||||
@@ -25,7 +26,7 @@ except:
|
||||
# tough luck
|
||||
pass
|
||||
|
||||
class FFNet:
|
||||
class FFNet(FanfictionSiteAdapter):
|
||||
def __init__(self, url):
|
||||
self.url = url
|
||||
parsedUrl = up.urlparse(url)
|
||||
|
||||
@@ -10,7 +10,9 @@ import urlparse as up
|
||||
import BeautifulSoup as bs
|
||||
import htmlentitydefs as hdefs
|
||||
|
||||
class FicWad:
|
||||
from adapter import *
|
||||
|
||||
class FicWad(FanfictionSiteAdapter):
|
||||
def __init__(self, url):
|
||||
self.url = url
|
||||
self.host = up.urlparse(url).netloc
|
||||
@@ -90,7 +92,7 @@ if __name__ == '__main__':
|
||||
url = 'http://www.ficwad.com/story/14536'
|
||||
data = u2.urlopen(url).read()
|
||||
host = up.urlparse(url).netloc
|
||||
fw = FicWad()
|
||||
urls = fw.extractIndividualUrls(data, host, url)
|
||||
fw = FicWad(url)
|
||||
urls = fw.extractIndividualUrls()
|
||||
pp.pprint(urls)
|
||||
print(fw.getText(data))
|
||||
Reference in New Issue
Block a user