#!/usr/bin/env python3 """ calling this python3 with any rrl url as a parameter will check every 10 min whether the author note has changed or, (and the following isn't fool proof), if there is a new chapter. Made for Aternus ETAs """ import urllib.request import sys, time, re def chercher(url): """ fetches the author note and the button next at the url """ fp = urllib.request.urlopen(url) mybytes = fp.read() page = mybytes.decode("utf8") fp.close() #boundaries of author note debut = page.find("portlet solid author-note-portlet\">") + 35 fin = page.find("<div class=\"chapter-inner chapter-content") #only if not found, then maybe new chapter suite = (page.find("<button class=\"btn btn-primary col-xs-4\" disabled=\"disabled\">Next") == -1) return suite, page[debut:fin] def main(url): compteur = 0 suite, new = chercher(url) previous = new print(re.sub('<[^>]*>', '', new)) print("+".join("-" for _ in range(40))) #we check the latest chapter regularly while previous == new and not suite: #please do not set lower time out of respect for royalroadl time.sleep(600) previous = new suite, new = chercher(url) compteur += 2 print("{} min".format(compteur)) if suite: #if there is a new chapter (not trollproof) print("<<<<<<< THERE MAY BE A NEW CHAPTER >>>>>>") else: #if the author note (hence the ETA) has changed print("<<<<<<< NEW AUTHOR NOTE >>>>>>") print(re.sub('<[^>]*>', '', new)) if __name__ == '__main__': if len(sys.argv) >1: main(sys.argv[1]) else: main("http://royalroadl.com/fiction/8463/the-arcane-emperor/chapter/181151/chapter-98-demonic-dungeon")
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question