HTTP help
BlitzPlus Forums/BlitzPlus Programming/HTTP help
| ||
I've been writing a program to assist in clan management in a free-to-play game called Crossfire. What I want it to do is access a page like this and create a list of all the clan's current members (shown in the column on the right). The problem is, I am new to using TCP and HTTP and I can't figure out how to access any page past the first (The links to each page of the member list involves javascript). Can anyone explain to me how I can access the other pages? Thanks in advance. Here's the guts of what I have so far. It just saves the source of the page in a text file for processing later. fileout=WriteFile("src.txt") Print "Connecting" tcp=OpenTCPStream( "clan.z8games.com",80 ) If Not tcp Print "Failed.":WaitKey:End WriteLine tcp,"GET http://clan.z8games.com/clanstat_cf.aspx?guildid=3751" WriteLine tcp,Chr$(10) While Not Eof(tcp) n$=ReadLine$(tcp) WriteLine fileout,n Print n Wend CloseTCPStream tcp CloseFile fileout |
| ||
This is the code you should have:fileout=WriteFile("src.txt") Print "Connecting" tcp=OpenTCPStream( "clan.z8games.com",80 ) If Not tcp Print "Failed.":WaitKey:End WriteLine tcp,"GET /clanstat_cf.aspx?guildid=3751 HTTP/1.1" WriteLine tcp,"Host: clan.z8games.com" WriteLine tcp,"User-Agent: BlitzPlusApplication" WriteLine tcp,"Connection: close" WriteLine tcp,"" While Not Eof(tcp) n$=ReadLine$(tcp) WriteLine fileout,n Print n Wend CloseTCPStream tcp CloseFile fileout |
| ||
That's good to know, but that part of the code was working fine already. I need to know how to load the other pages. I know it involves a Postback but I don't know how to translate that into workable blitz code. |
| ||
That's good to know, but that part of the code was working fine already. Which is surprising because it shouldn't have worked the way you coded it. I'm not sure how to do the _doPostBack() javascript function because I don't know javascript. :) However, you could always Google or do some Wikipedia searching on how javascript functions are called in HTML code. |
| ||
Alternatively, would it be easier to get the source from an htmlview gadget? I've only found bmax code though, and I need b+. |
| ||
Well, you are already getting the source of the page with the code above. But, here is the source code for that Javascript function://<![CDATA[ var theForm = document.forms['aspnetForm']; if (!theForm) { theForm = document.aspnetForm; } function __doPostBack(eventTarget, eventArgument) { if (!theForm.onsubmit || (theForm.onsubmit() != false)) { theForm.__EVENTTARGET.value = eventTarget; theForm.__EVENTARGUMENT.value = eventArgument; theForm.submit(); } } //]]> I don't know what can be done with it, but there it is to look at. :) |
| ||
I could use an htmlview to get the source of the other pages as well:HtmlViewGo html,"http://clan.z8games.com/clanstat_cf.aspx?guildid=3751" HtmlViewGo html,"javascript:__doPostBack('ctl00$Main$GridView_memberlist','Page$2')" ...loads the 2nd page correctly, but I don't know how to extract the source. |