• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 11:37
CET 17:37
KST 01:37
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10
Community News
Weekly Cups (Dec 1-7): Clem doubles, Solar gets over the hump1Weekly Cups (Nov 24-30): MaxPax, Clem, herO win2BGE Stara Zagora 2026 announced15[BSL21] Ro.16 Group Stage (C->B->A->D)4Weekly Cups (Nov 17-23): Solar, MaxPax, Clem win3
StarCraft 2
General
Weekly Cups (Dec 1-7): Clem doubles, Solar gets over the hump Chinese SC2 server to reopen; live all-star event in Hangzhou Maestros of the Game: Live Finals Preview (RO4) BGE Stara Zagora 2026 announced Weekly Cups (Nov 24-30): MaxPax, Clem, herO win
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament Tenacious Turtle Tussle StarCraft2.fi 15th Anniversary Cup RSL Offline Finals Info - Dec 13 and 14! StarCraft Evolution League (SC Evo Biweekly)
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 503 Fowl Play Mutation # 502 Negative Reinforcement Mutation # 501 Price of Progress Mutation # 500 Fright night
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ [BSL21] RO8 Bracket & Prediction Contest Let's talk about Metropolis Foreign Brood War BW General Discussion
Tourneys
[ASL20] Grand Finals Small VOD Thread 2.0 [Megathread] Daily Proleagues [BSL21] RO16 Group D - Sunday 21:00 CET
Strategy
Fighting Spirit mining rates Current Meta Game Theory for Starcraft How to stay on top of macro?
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread EVE Corporation Path of Exile ZeroSpace Megathread
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Mafia Game Mode Feedback/Ideas Survivor II: The Amazon Sengoku Mafia TL Mafia Community Thread
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread YouTube Thread European Politico-economics QA Mega-thread Things Aren’t Peaceful in Palestine
Fan Clubs
White-Ra Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece Movie Discussion!
Sports
2024 - 2026 Football Thread Formula 1 Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
TL+ Announced Where to ask questions and add stream?
Blogs
How Sleep Deprivation Affect…
TrAiDoS
I decided to write a webnov…
DjKniteX
James Bond movies ranking - pa…
Topin
Thanks for the RSL
Hildegard
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1170 users

autofan: A tool for updating fan clubs

Blogs > Loser777
Post a Reply
Loser777
Profile Blog Joined January 2008
1931 Posts
Last Edited: 2013-09-06 01:38:33
September 06 2013 01:08 GMT
#1
The member lists of most fan clubs, are, at the moment, unmanageable. Some of the larger ones haven't had their lists updated in over two years.

I'm currently working on a web scraper which would allow these lists to be updated automatically, without any manual labor.
https://github.com/eqy/autofan

The current development environment is Arch GNU/Linux, and I've ported it over to Ubuntu 12.04 with almost no issues (after fixing some compatibility issues with Ubuntu's slightly staler libraries). If you'd like to build it, simply clone the repository and make sure you have the libraries specified in the README. If you encounter any problems trying to build, let me know.

It is trivial to build: [animated-gif]
http://i.imgur.com/I4EmOgX.gif

And trivial to use: [animated-gif]
http://i.imgur.com/H05aOgQ.gif


It's still in the very early stages of development, so there are still a number of obvious issues:
  • The rules for adding people to fan clubs are still very simple at the moment, and there are only a few of them.
  • People can be added multiple times. This most obvious cause of this is through quotes (see below). This is trivially fixable through any number of tools (e.g. sort -u, regex, etc.).
  • Quotes are not handled well--the parser can't distinguish what someone actually said and what the person they're quoting said. This is a slightly annoying issue, because despite the copious amounts of tables that TL uses, quotes are not explicitly tables--so the parser that I'm using doesn't identify quotes as separate elements. The most obvious solution I see at the moment is to do some kind of regex matching where posts that say "...wrote:" are checked against previous posts. Finding posts that likely contain quotes is trivial, but the matching step would be computationally expensive.
  • It still spits out mountains of debug information to stderr (actual output goes to stdout) because I still need the debug information to add features/fix the issues above.


The plan is to either eventually port it over to Windows after slapping on some sort of qt-based interface so it becomes usable for the 99% of TL or to launch it as some sort of web app. Both are equally foreign territory for me.
If you feel like contributing, feel free to send me a pull request! When development quiets down, I also plan on repackaging the core of this project (a library called tltopic) so that it can be used for other projects that want to parse TL threads.

History of the project:
(I don't have db access scraping is all I can do #YOLO)

I began thinking about this around two weeks ago and have been lazily hacking at it since. After my REU program ended this summer, I realized that I had pretty much been writing exclusively MATLAB for the last year or so. That year or so destroyed whatever tiny amount of coding chops in C/C++ I had (my background is not in CS), and my little weekend side projects in Python/Arduino were not helping. The implementation language of C++ reflects my need to refresh my knowledge--seriously, who writes web scrapers in C++ these days? I think this justifies the language choice as mental masturbation, not masochism.

I basically had zero knowledge of any of the non-standard libraries I used in this project (libcurl, libtidy, libxml2, boost) before I started. Everything was inspired by this single stack overflow post: http://stackoverflow.com/a/834879. Because of the odd mishmash of libraries used, the implementation is about 80% C++ with 20% of C style code thrown in to play nice with curl, tidy, and boost.

The funniest part of the code at the moment is the step I call the "post-table getting step". Basically, it traverses the syntax tree generated by libxml2 to find the "juicy table" (I was kind of out of it when coming up with names at this point) which consists of the all of the posts in a given thread. The method I used to find this table is both hilarious and ugly at the same time. Basically, as libcurl is not "logged in" to TL, the bottom of the posts contains that "Please log in or register to reply." field. I search for the smallest syntax tree that contains this line AND the header to a forum post (e.g. [Username] PM ... Profile Quote...). Considering that this table is buried between dozens of layers, this method is surprisingly robust.

Often I find that what I learn during these projects ends up being more interesting than the results--and here's a brief selection of some things so far:
  • Makefiles are amazing
  • Good initial design goes a long way
  • Valgrind is your salvation in C++
  • Make will include obvious directories for libraries by default
  • Pay attention to ugly/non-intuitive include directory layouts
  • Playing nice with C-style code may mean you need to break encapsulation
  • Give the type of an argument that will be passed but no name to let the compiler know you're intentionally not using it
  • Header-only libraries exist
  • g++ seems to dislike = {0}, but will stop complaining if you use the lower level memset() instead
  • If the API poorly documents the options in a library, just fucking read the source and figure out what's available
  • HTML has ugly characters like &nbsp that will break XML parsers
  • TL's site layout is really complicated (seriously, look at the source for this page)
  • References to single characters are not null-terminated, and will riddle your strings with garbage if you expect them to be
  • Unprintable characters may ruin your day
  • If you're getting a pointer to a data structure from a function, you've got to ask yourself one question. Do you feel lucky? Was the data allocated before you called the function? If not, you better delete that shit.
  • Malloc and delete do not mix well, as do new and free. Check your API to see how you should dispose of buffers.
  • If you use std::string, expect Valgrind to find "still-reachable" leaks





*****
6581
GHOSTCLAW
Profile Blog Joined February 2008
United States17042 Posts
September 06 2013 01:57 GMT
#2
good luck ^^

On September 06 2013 10:08 Loser777 wrote:
(I don't have db access scraping is all I can do #YOLO)


5/5
PhotographerLiquipedia. Drop me a pm if you've got questions/need help.
tarpman
Profile Joined February 2009
Canada719 Posts
Last Edited: 2013-09-06 02:02:50
September 06 2013 02:01 GMT
#3
Nice work, and neat program! I've recently used libcurl and libxml2 at work, so I was interested in reading your code.

Is there a reason why you're searching the DOM manually instead of running an XPath query? I only played with xmllint for a few seconds, but I feel like something like
//td[@class="forumPost"]/text()
ought to match what you're looking for.

Concerning the struct initialization: as I understand it the usual way to do it in C++ is
TidyBuffer output = {};
which will initialize all members to their default values, rather than 0. When you just have data members it doesn't matter, but if your struct contains objects they might need to be initialized. See this Stack Overflow question for more.
Saving the world, one kilobyte at a time.
Loser777
Profile Blog Joined January 2008
1931 Posts
September 06 2013 02:21 GMT
#4
On September 06 2013 11:01 tarpman wrote:
Nice work, and neat program! I've recently used libcurl and libxml2 at work, so I was interested in reading your code.

Is there a reason why you're searching the DOM manually instead of running an XPath query? I only played with xmllint for a few seconds, but I feel like something like
//td[@class="forumPost"]/text()
ought to match what you're looking for.

Concerning the struct initialization: as I understand it the usual way to do it in C++ is
TidyBuffer output = {};
which will initialize all members to their default values, rather than 0. When you just have data members it doesn't matter, but if your struct contains objects they might need to be initialized. See this Stack Overflow question for more.

Hmm, I didn't know about that part of API for libxml2 yet--I'll have to check that out! It could potentially fix the quote problem I was having!

As for the variable initialization, it probably doesn't matter as it's just a buffer that's going to get overwritten anyway. As it's not an object, I prefer using memset. Given that the tidy implementation appears to be strictly C, I don't think the struct is going to contain any objects .
6581
Please log in or register to reply.
Live Events Refresh
WardiTV 2025
12:00
Group Stage 1 - Group D
WardiTV1133
ComeBackTV 554
TaKeTV 345
IndyStarCraft 226
LamboSC2152
Rex116
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
IndyStarCraft 226
LamboSC2 152
Rex 116
BRAT_OK 90
MindelVK 17
MaxPax 1
StarCraft: Brood War
Britney 34184
Bisu 2706
Larva 989
Light 815
Mini 662
Hyuk 349
Snow 311
hero 256
firebathero 252
ggaemo 159
[ Show more ]
Rush 157
Mind 94
Hyun 79
Movie 47
910 43
sorry 33
soO 33
Terrorterran 21
HiyA 11
Dota 2
Gorgc5818
singsing3317
qojqva2792
Dendi904
syndereN254
XcaliburYe130
League of Legends
rGuardiaN40
Counter-Strike
fl0m6282
zeus549
byalli420
Other Games
B2W.Neo1097
Beastyqt752
DeMusliM614
hiko567
Lowko380
crisheroes367
RotterdaM153
QueenE78
Trikslyr58
ArmadaUGS40
Organizations
Other Games
BasetradeTV82
StarCraft: Brood War
lovetv 8
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 18 non-featured ]
StarCraft 2
• poizon28 25
• IndyKCrew
• sooper7s
• AfreecaTV YouTube
• intothetv
• Kozan
• Migwel
• LaughNgamezSOOP
StarCraft: Brood War
• Michael_bg 15
• FirePhoenix10
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• WagamamaTV411
• Noizen37
League of Legends
• Nemesis2171
• Jankos1846
Other Games
• Shiphtur92
Upcoming Events
StarCraft2.fi
23m
WardiTV 2025
19h 23m
Big Brain Bouts
1d
RSL Revival
1d 11h
StarCraft2.fi
1d 17h
IPSL
2 days
Sziky vs JDConan
RSL Revival
2 days
Classic vs TBD
herO vs Zoun
WardiTV 2025
2 days
IPSL
3 days
Tarson vs DragOn
Wardi Open
3 days
[ Show More ]
Monday Night Weeklies
4 days
Replay Cast
4 days
Sparkling Tuna Cup
4 days
The PondCast
6 days
Liquipedia Results

Completed

Acropolis #4 - TS3
RSL Revival: Season 3
Kuram Kup

Ongoing

IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
YSL S2
BSL Season 21
Slon Tour Season 2
WardiTV 2025
META Madness #9
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22

Upcoming

BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Big Gabe Cup #3
RSL Offline Finals
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.