Random

## Python Script for Trope Overdosed:

Total posts: [4]
For those who want a perfectly accurate count on Trope Overdosed, check out this Python script.

To get an accurate number of wicks for works where you have to add up wicks for several pages, you click each of the links for this work. You look at the source code of the HTML page, scroll down, and copy the line that starts with "<div class="wmglead" ><span style="color:chocolate;". (It's often a very long line, because it contains all the wicks, but treat it as a single one.) Copy this line (for each file) into a simple .txt file, and save it when you did this for all the links. Then you open the python script in your editor and change line 3 to the file address, instead of C:to.txt. Afterwards, you simply run the python script and check what it says about individual results. If you don't have a Python environment, you can download all the necessary stuff at www.python.org ).

And here, the script itself (it's jumbled up here because of the whitespace rules, but in the page source, it appears correct, so copy it from there):
list = [] file = open('C:\\to.txt', 'r') lines = file.readlines() file.close() for line in lines: subList = re.findall(r'href="([^"]+)"', line) for element in subList: list.append(element.lower()) list.sort() print str(len(list)) + " Elements" # sort out WMG, JBM, TT, Tropers for i in range(len(list) - 1, -1, -1): if list[i].startswith("http://tvtropes.org/pmwiki/pmwiki.php/tropers/") or list[i].startswith("http://tvtropes.org/pmwiki/pmwiki.php/tropertales/") or list[i].startswith("http://tvtropes.org/pmwiki/pmwiki.php/wmg/") or list[i].startswith("http://tvtropes.org/pmwiki/pmwiki.php/justbugsme/"): list[i:i+1] = [] for i in range(len(list) - 1, -1, -1): if list[i] == list[i-1]: list[i-1:i] = [] print str(len(list)) + " individual Elements"

edited 20th Dec '10 5:22:56 AM by Frank75

Fuhrmann, es kostet dir noch dein Leben
2 Tzetze20th Dec 2010 10:05:19 AM from a converted church in Venice, Italy
bump

I looked at the web addresses and it included stuff like Troper Tales and It Just Bugs Me, which no longer exist. Plus, I couldn't find phrases like "wmglead" in the HTML source code. Can someone care to update this Python script?
I've written a new trope-count script.

Unfortunately, TV Tropes doesn't standardize article structure, so it won't always work.

Example:

user@host\$ ./tvtropes_count.py Film/MontyPythonAndTheHolyGrail
Film/MontyPythonAndTheHolyGrail: 210 tropes

edited 15th May '13 1:41:47 AM by MechanicalSnail

The system doesn't know you right now, so no post button for you.
You need to Get Known to get one of those.

Total posts: 4