Created
June 6, 2012 18:47
-
-
Save rystraum/2883846 to your computer and use it in GitHub Desktop.
eRepublik market scraper
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
// ==UserScript== | |
// @name Erepublik | |
// @namespace erep | |
// @include http://economy.erepublik.com/en/* | |
// @version 1 | |
// ==/UserScript== | |
var console = unsafeWindow.console; | |
var url = window.location; | |
url = url.toString(); | |
var country, item_type, item_quality; | |
var regex = /\/([0-9]+)/ig; | |
var result = url.match(regex); | |
if (result.length >= 3) { | |
country = result[0]; | |
item_type = result[1]; | |
item_quality = result[2]; | |
} | |
console.log(country); | |
console.log(item_type); | |
console.log(item_quality); | |
var table = document.getElementById("marketplace").getElementsByTagName("table")[0].getElementsByTagName("tbody")[0]; | |
if (table) { | |
table = escape(table.innerHTML); | |
GM_xmlhttpRequest({ | |
method: "POST", | |
url: "http://erep.webbyapp.com/receive", | |
data: "item[country]="+country+"&item[item_type]="+item_type+"&item[item_quality]="+item_quality+"&item[data]="+table, | |
headers: { | |
"Content-Type": "application/x-www-form-urlencoded" | |
} | |
}); | |
} else { | |
console.log("don't see no tables"); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment