Created
November 17, 2014 21:27
-
-
Save stravant/f4c9eaca263ee5c84d54 to your computer and use it in GitHub Desktop.
Grab posts from the Roblox forums from your tracked threads
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/lua | |
local tracked_url = "http://www.roblox.com/Forum/User/MyForums.aspx" | |
local base_url = "http://www.roblox.com/Forum/ShowPost.aspx?PostID=" | |
local cookie = "(Paste your .ROBLOSECURITY cookie which you can find in your browser cookies, don't share this script with it still pasted in there obviously)" | |
function cmd(txt) | |
os.execute(txt) | |
end | |
function fread(filename) | |
return io.open(filename, 'r'):read("*all") | |
end | |
function openwrite(filename) | |
return io.open(filename, 'w+') | |
end | |
cmd('curl --cookie ".ROBLOSECURITY="'..cookie..' '..tracked_url..' > tracked.html') | |
local tracked_html = fread('tracked.html') | |
local urls_txt = openwrite('urls.txt') | |
local post_id_list = {} | |
-- Top part -> tracked threads, Bottom part -> recent threads | |
local top_part = tracked_html:find("<h2>Your Last ") | |
tracked_html = tracked_html:sub(1, top_part) | |
-- Find post IDs | |
for id in tracked_html:gmatch('href="/Forum/ShowPost.aspx%?PostID=(%d+)"><div') do | |
urls_txt:write(id.."\n") | |
table.insert(post_id_list, tonumber(id)) | |
end | |
-- Create a folder for the posts | |
cmd[[mkdir data]] | |
-- For each post Id, get that post | |
for _, id in pairs(post_id_list) do | |
cmd('curl --cookie ".ROBLOSECURITY="'..cookie..' '..base_url..id..' > '..id..'.html') | |
end | |
print("Done, saved "..(#post_id_list).." threads.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment