mIRC Homepage
Posted By: Belhifet Sock question...I think. Oh gawd. - 15/07/14 12:04 AM
Ok, I'm writing a script to pull information from a website. OP.GG is the site. This is an example of a page I might want to pull information from http://na.op.gg/summoner/userName=lldeathcowll . Now if the pages just automatically looked like that, I'd be good to go. But as it turns out there is a 'Renew Stats' button on that page, and while it automatically runs that once you open the page when I just 'get' the page obviously that never run. So if its a user that has never been looked up before(no info on page) or hasn't been looked up recently(inaccurate info on page) the result I get aren't right. I'd like to click that button before I try to get info, but I legitimately have no idea how.

I assume this is possible, but I suppose I can look for another information source besides this page even though there are a few reason why I'd prefer this page over other sources.
Posted By: Loki12583 Re: Sock question...I think. Oh gawd. - 15/07/14 12:46 AM
When you press the Renew button multiple posts are made: POST /summoner/ajax/updaterstatus.json/, with this data: summonerId=26151959. That number can be obtained from the original source:
Code:
<button class="ladda-button _refreshSummonerInfo summonerRefreshButton" data-color="mint" data-size="xl" data-style="expand-right" onclick="SummonerRefresh.RefreshUser(this, 26151959)" data-summoner-id="26151959" title="Updating llDeathCowll's stats to latest stats.">
I assume you can store this ID if you're only getting data for yourself.

Responses:
Code:
{"finish":false,"current":0,"delay":300,"status":true}
{"finish":false,"current":0.99,"delay":300,"status":true}
{"finish":false,"current":0.99,"delay":300,"status":true}
{"finish":false,"current":0.99,"delay":300,"status":true}
{"finish":false,"current":0.99,"delay":300,"status":true}
{"finish":true,"current":0.99,"status":true}


Once you get the finish:true I assume you can grab the entire page again and it will contain the data. That said, APIs exist for a reason and it's probably best to look for one if it exists rather than grabbing entire pages of html.

In the future you can find all of this information yourself using Chrome's (or other browser's) developer tools. You can right click the button and select "Inspect element" to see what the button's supposed to do. Beyond that you can switch to the Network tab to view all of the requests/responses Chrome is making when you press the button.
Posted By: Belhifet Re: Sock question...I think. Oh gawd. - 15/07/14 01:31 AM
blush Loki responded to muh post..*squeel*

I wish the api for league let me do what I want..but. It allows me like 10 requests in however much time. WHICH as it turns out isnt enough. A game of league of legends normally has 10 people in it. So I could request info on who is in a game with someone, but then I couldn't request info on the people in that game. It possible I'm just derpie though.

I looked through the inspect element and even with this info infront of me, I don't know enough to find "POST /summoner/ajax/updaterstatus.json/"

I'm pretty sure I can figure out how to use post(i've never used it). Sometimes when I'm trying to 'code' something everything I'm trying seems very new and overwhelming and other times something that used to be new and overwhelming seems easy. In this case there was a bunch of stuff that was new to me so thanks for the help.
Posted By: Loki12583 Re: Sock question...I think. Oh gawd. - 15/07/14 01:37 AM
The button calls some javascript, I didn't feel like following it all through either. Ctrl+Shift+J brings up the developer tools, on the Network tab watch what happens when you press the button. Select one of the requests and you can view the full request and response.
Posted By: Belhifet Re: Sock question...I think. Oh gawd. - 15/07/14 01:55 AM
Originally Posted By: Loki12583
The button calls some javascript, I didn't feel like following it all through either. Ctrl+Shift+J brings up the developer tools, on the Network tab watch what happens when you press the button. Select one of the requests and you can view the full request and response.


BTW, I did get my script working. So thank you...and I had no idea how to properly use the developer tools and I do see how you got that information now so thank you very much.
Posted By: patrickplays Re: Sock question...I think. Oh gawd. - 17/07/14 08:26 PM
use the riot api! :0
Posted By: Belhifet Re: Sock question...I think. Oh gawd. - 18/07/14 01:59 AM
It seemed like it was giving me very limited requests..Like not enough to actually do what i wanted...Maybe its enough if it let me look up multiple people in a single request. This does what I want though...and its finished, so unless I get super duper boredarino, or it stops working, I'll probably just stick with this. God da...now I'm gonna have to..Thanks for posting patrick...BibleThump.
© mIRC Discussion Forums