Created
September 20, 2011 09:55
-
-
Save cabron/1228767 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require 'net/http' | |
$page = Regexp.new(%{<em>([0-9]+)</em></span></a></li><li><a href="[^"]+"><span><em>nast}) | |
$dodany = %{dodany przez <a .+>%s</a>[\\s]+.*z domeny: <a href="([^"]+)"} | |
user = ['rtoip7', 'reddigg'] | |
def kazda_strona w, url | |
i = s = 1 | |
while i <= s | |
return if yield body = w.get("/ludzie/#{url}/strona/"+i.to_s).body | |
if m = body.match($page) | |
s = m[1].to_i | |
end | |
i += 1; sleep 1 | |
end | |
end | |
Net::HTTP.start('www.wykop.pl') do |w| | |
kazda_strona w, "followers/#{user[0]}" do |body| | |
if body['dodane przez '+user[1]] | |
puts "Obserwowany" | |
true | |
end | |
end | |
kazda_strona w, "followed/#{user[0]}" do |body| | |
if body['dodane przez '+user[1]] | |
puts "Obserwuje" | |
true | |
end | |
end | |
[user, user.reverse].product([['wykopane', ' wykopal '], ['komentowane', ' skomentowal ']]).each do |user, action| | |
kazda_strona w, action[0]+'/'+user[0] do |body| | |
body.scan(Regexp.new $dodany % user[1]) {|m| puts user[0] + action[1] + m[0]} | |
false | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment