Skip to content

Instantly share code, notes, and snippets.

Created February 28, 2012 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1933290 to your computer and use it in GitHub Desktop.
Save anonymous/1933290 to your computer and use it in GitHub Desktop.
USER_AGENT = ''
USERNAME = ''
PASSWORD = ''
require 'net/http/persistent'
items = File.read('items.txt').split "\n"
Conn = Net::HTTP::Persistent.new
Conn.override_headers['User-Agent'] = USER_AGENT
$neopets, $attic = URI 'http://www.neopets.com', '/halloween/garage.phtml'
Conn.headers['Referer'] = ($neopets + $attic).to_s
def login
post = Net::HTTP::Post.new '/login.phtml'
post.set_form_data username: USERNAME, password: PASSWORD
resp = Conn.request $neopets, post
Conn.headers['Cookie'] = resp.get_fields('Set-Cookie').map { |c| c.split(';')[0] } * ';'
end
login
while 1
sleep(420 - (Time.now.to_i - 592) % 420)
post = Net::HTTP::Post.new $attic
3.times do
html = Conn.request($neopets + $attic).body
stock = html.scan(/(\d+)\].+?buy.+?(.+?) at/)
stock.reject { |s| !items.index(s[1]) }.sort_by { |e| items.index e[1] }.each do |s|
post.set_form_data purchase: 1, oii: s[0], neopets: 123
Conn.request($neopets + $attic, post)
end
sleep 2
end
login unless html.include? USERNAME
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment