Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 28 lines (23 sloc) 0.827 kb
babaf40 @palfrey Add Fanfiction.net generator
authored
1 from sys import argv
2 from urlgrab import Cache
3 from codecs import open
4 import re
5
6 cache = Cache()
7 url = argv[1]
8 data = cache.get(url).read()
9 open("dump", "wb", "utf-8").write(data)
10
51bd565 @palfrey Fanfiction: Author and Title formats were wrong for a new series
authored
11 title = re.search("<title>(.+?) Chapter \d+", data)
babaf40 @palfrey Add Fanfiction.net generator
authored
12 title = title.groups()
51bd565 @palfrey Fanfiction: Author and Title formats were wrong for a new series
authored
13 author = re.search("Author:</span> <a[^>]+?href='/u/\d+/[^']+'>([^<]+)</a>", data)
babaf40 @palfrey Add Fanfiction.net generator
authored
14 author = author.groups()[0]
15 id = re.search("/s/(\d+)", url)
16 id = id.groups()[0]
17
18 print """series {
19 name: "%s"
20 description: "%s"
21 author: "%s"
bb97175 @palfrey Fanfiction.net seems to update faster on the mobile site
authored
22 startPage: "http://m.fanfiction.net/s/%s/1"
23 titlePattern: "<img src='http://[^']+/balloon.png' class='mt icons'>[\d,]+</a></span>(.+?)<br>"
24 contentPattern: "class='storycontent' id='storycontent' >(.+?)</div></div>.*?<hr size=1"
25 nextPattern: "<a href='(/s/\d+/\d+/)'>Next &#187;</a>"
26 }"""%(title[0].replace(" ",""), title[0], author, id)
babaf40 @palfrey Add Fanfiction.net generator
authored
27
Something went wrong with that request. Please try again.