• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 14:24
CET 20:24
KST 04:24
  • 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
HomeStory Cup 28 - Info & Preview11Rongyi Cup S3 - Preview & Info3herO wins SC2 All-Star Invitational14SC2 All-Star Invitational: Tournament Preview5RSL Revival - 2025 Season Finals Preview8
Community News
Weekly Cups (Jan 19-25): Bunny, Trigger, MaxPax win3Weekly Cups (Jan 12-18): herO, MaxPax, Solar win0BSL Season 2025 - Full Overview and Conclusion8Weekly Cups (Jan 5-11): Clem wins big offline, Trigger upsets4$21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7)38
StarCraft 2
General
HomeStory Cup 28 - Info & Preview StarCraft 2 Not at the Esports World Cup 2026 Weekly Cups (Jan 19-25): Bunny, Trigger, MaxPax win Oliveira Would Have Returned If EWC Continued herO wins SC2 All-Star Invitational
Tourneys
HomeStory Cup 28 KSL Week 85 $21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7) OSC Season 13 World Championship $70 Prize Pool Ladder Legends Academy Weekly Open!
Strategy
Simple Questions Simple Answers
Custom Maps
[A] Starcraft Sound Mod
External Content
Mutation # 510 Safety Violation Mutation # 509 Doomsday Report Mutation # 508 Violent Night Mutation # 507 Well Trained
Brood War
General
[ASL21] Potential Map Candidates BGH Auto Balance -> http://bghmmr.eu/ Bleak Future After Failed ProGaming Career BW General Discussion Potential ASL qualifier breakthroughs?
Tourneys
[Megathread] Daily Proleagues Small VOD Thread 2.0 Azhi's Colosseum - Season 2 [BSL21] Non-Korean Championship - Starts Jan 10
Strategy
Zealot bombing is no longer popular? Simple Questions, Simple Answers Current Meta Soma's 9 hatch build from ASL Game 2
Other Games
General Games
Nintendo Switch Thread Battle Aces/David Kim RTS Megathread Path of Exile Mobile Legends: Bang Bang Beyond All Reason
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Gold Bars & Gold Nuggets for sale+27 73 799 4524
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 Vanilla Mini Mafia
Community
General
US Politics Mega-thread Canadian Politics Mega-thread Russo-Ukrainian War Thread European Politico-economics QA Mega-thread Things Aren’t Peaceful in Palestine
Fan Clubs
The herO Fan Club! The IdrA Fan Club
Media & Entertainment
[Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
Let's Get Creative–Video Gam…
TrAiDoS
My 2025 Magic: The Gathering…
DARKING
Life Update and thoughts.
FuDDx
How do archons sleep?
8882
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1537 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
HomeStory Cup
12:00
Day 2
TaKeTV4339
ComeBackTV 1156
SteadfastSC496
IndyStarCraft 492
TaKeSeN 332
Rex107
3DClanTV 95
CosmosSc2 81
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SteadfastSC 496
IndyStarCraft 492
ProTech119
Rex 107
CosmosSc2 81
BRAT_OK 64
JuggernautJason56
StarCraft: Brood War
Shuttle 295
Larva 265
Rock 31
Free 30
Shine 20
soO 12
Sacsri 11
ivOry 5
Dota 2
qojqva2373
Dendi699
420jenkins506
monkeys_forever58
Counter-Strike
fl0m4099
kRYSTAL_41
Heroes of the Storm
Liquid`Hasu520
Khaldor384
Trikslyr77
MindelVK10
Other Games
FrodaN7345
Grubby3032
Mlord598
crisheroes329
KnowMe99
ToD42
Organizations
Other Games
EGCTV1385
gamesdonequick1236
BasetradeTV33
angryscii18
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 19 non-featured ]
StarCraft 2
• printf 21
• iHatsuTV 15
• Response 2
• Kozan
• AfreecaTV YouTube
• sooper7s
• intothetv
• IndyKCrew
• LaughNgamezSOOP
• Migwel
StarCraft: Brood War
• FirePhoenix35
• 80smullet 11
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• WagamamaTV512
League of Legends
• Jankos2767
• imaqtpie2147
Counter-Strike
• Shiphtur262
Upcoming Events
Replay Cast
4h 37m
HomeStory Cup
17h 37m
OSC
17h 37m
Replay Cast
1d 4h
Replay Cast
2 days
Wardi Open
2 days
WardiTV Invitational
3 days
The PondCast
4 days
WardiTV Invitational
4 days
Liquipedia Results

Completed

Escore Tournament S1: W6
OSC Championship Season 13
Underdog Cup #3

Ongoing

CSL 2025 WINTER (S19)
KCM Race Survival 2026 Season 1
Acropolis #4 - TS4
Proleague 2026-01-31
Rongyi Cup S3
HSC XXVIII
Nations Cup 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8

Upcoming

Escore Tournament S1: W7
Escore Tournament S1: W8
Acropolis #4
IPSL Spring 2026
uThermal 2v2 2026 Main Event
Bellum Gens Elite Stara Zagora 2026
LiuLi Cup: 2025 Grand Finals
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League Season 23
ESL Pro League Season 23
PGL Cluj-Napoca 2026
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 © 2026 TLnet. All Rights Reserved.