Recent

Author Topic: Synapse POST  (Read 5988 times)

Middlecope

  • Jr. Member
  • **
  • Posts: 72
Synapse POST
« on: October 24, 2012, 04:54:22 pm »
I like to get lottery numbers from a website: http://wnk.cc/default.aspx
using the following code:
Code: [Select]
HTTP.ProxyHost := '';
    HTTP.ProxyPort := '';
    HTTP.MimeType := 'application/x-www-form-urlencoded';
    HTTP.HTTPMethod('GET','http://wnk.cc/default.aspx');
    lijst.LoadFromStream(HTTP.Document);
   Get_lottery_numbers; 
It is OK
Down on the page you can chose the second page and firefox shows me the following link:
'javascript:__doPostBack('ctl00$bodyCenterContentPlaceHolder$periodDateGridView','Page$2')
To get page number 2 I wrote the follwing code:
Code: [Select]
   URLData:= 'txtrn=javascript:_doPostBack(''ctl00$bodyCenterContentPlaceHolder$periodDateGridView'',''Page$2'')';
   HTTP.Document.Write(Pointer(URLData)^, Length(URLData));
       HTTP.HTTPMethod('POST','http://wnk.cc/default.aspx');
      lijst.LoadFromStream(HTTP.Document);
   Get_lottery_numbers;       
Unfortunately I get still the first page.
Omitting the "txtrn="  same result.
Suggestions are highly appreciated. Thanks

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Synapse POST
« Reply #1 on: October 24, 2012, 05:07:59 pm »
Try:
Code: [Select]
HTTP.Document.Write(URLData[1], Length(URLData));
I mean, string type character data doesn't start from the original pointer. @varString is different than @varString[1] (which is first character).
« Last Edit: October 24, 2012, 05:09:49 pm by User137 »

Middlecope

  • Jr. Member
  • **
  • Posts: 72
Re: Synapse POST
« Reply #2 on: October 24, 2012, 08:44:28 pm »
Unfortunately, that doesn't do the job.
More suggestions?

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Synapse POST
« Reply #3 on: October 24, 2012, 10:16:34 pm »
javascript:__doPostBack
you wrote
javascript:_doPostBack

That's all i can see for now  ;)

Middlecope

  • Jr. Member
  • **
  • Posts: 72
Re: Synapse POST
« Reply #4 on: October 24, 2012, 11:57:10 pm »
Thanks
I have corrected the 1 underscore to 2  Same result.
Maybe I have to prefix the URLData with something else then:  txtnr=
Any hint is welcome

BeniBela

  • Hero Member
  • *****
  • Posts: 769
    • homepage
Re: Synapse POST
« Reply #5 on: October 25, 2012, 12:41:50 am »
Well of course that does not work, because it is a javascript function call and not a post data.

The post data is all the value of all the <input> fields on the webpage, i.e.:

Quote
__VIEWSTATE=%2FwEPDwULLTEwNTUxNzY2MjIPZBYCZg9kFgICAw9kFgICBQ9kFgoCAQ9kFgwCAQ8WAh4LXyFJdGVtQ291bnQCBRYKZg9kFgJmDxUBA1dOS2QCAQ9kFgJmDxUBBVNtYXJ0ZAICD2QWAmYPFQEFRGFpbHlkAgMPZBYCZg8VAQpTYW50byBEb20uZAIED2QWAmYPFQEGRGlhcmlvZAICDxYCHwACBRYKZg9kFgJmDxUBBDg0NDdkAgEPZBYCZg8VAQQ5MzQ1ZAICD2QWAmYPFQEEMjEzMGQCAw9kFgJmDxUBBDU1NDhkAgQPZBYCZg8VAQQ0MzU2ZAIDDxYCHwACBRYKZg9kFgJmDxUBBDQzNzVkAgEPZBYCZg8VAQQyODE3ZAICD2QWAmYPFQEEMDU2MWQCAw9kFgJmDxUBBDIyOThkAgQPZBYCZg8VAQQwNDAxZAIEDxYCHwACBRYKZg9kFgJmDxUBBDMzNTRkAgEPZBYCZg8VAQQ1NDU0ZAICD2QWAmYPFQEEMzE5OWQCAw9kFgJmDxUBBDI5NjdkAgQPZBYCZg8VAQQyODE3ZAIFDw9kPCsABgEAEBYBZhYBFgIeDlBhcmFtZXRlclZhbHVlZBYBAgNkAgYPD2Q8KwAGAGQCAw8QDxYCHgtfIURhdGFCb3VuZGdkEBUmDDIwMTIgb2t0b2Jlcg4yMDEyIHNlcHRlbWJlcg0yMDEyIGF1Z3VzdHVzCTIwMTIganVsaQkyMDEyIGp1bmkIMjAxMiBtZWkKMjAxMiBhcHJpbAoyMDEyIG1hYXJ0DTIwMTIgZmVicnVhcmkMMjAxMiBqYW51YXJpDTIwMTEg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bCgKOpuDbCgKOpuzbCgKOpvjbCgKOpuTbCgKOpvDbCgKOpvzbCgKOpsjbCgKPpsD%2BBQKPptz%2BBQKPptj%2BBQKOpvz%2BBQKOpvj%2BBQKOpvT%2BBQKOpvD%2BBQKOpsz%2BBQKOpsj%2BBQKOpsT%2BBQKOpsD%2BBQKOptz%2BBQKPptSRDAKPpqCSDAKPpqySDAKOpsCRDAKOpsyRDAKOptiRDAKOpsSRDAKOptCRDAKOptyRDAKOpqiSDAKOptSRDAKOpqCSDALqycW6AQLqydG6AQLqyd26AQLpydG6AQLU66jtAwLutvPICQKgo97QAgKYr6u2BwL1nJezBwKFoN%2BzBgKY2NnLDwKz57%2BUCQKz58OUCQKz59eUCUo971DhwuqCYdja8WbdrOVBJTWWUB5Cfh4b8ZP4DPEA&ctl00%24bodyCenterContentPlaceHolder%24todayDateLotteryDraw%24dateHiddenField=23%2F10%2F2012%2018%3A29%3A51&ctl00%24bodyCenterContentPlaceHolder%24periodDateGridView%24ctl02%24dateLotteryDraw%24dateHiddenField=22%2F10%2F2012%200%3A00%3A00&ctl00%24bodyCenterContentPlaceHolder%24periodDateGridView%24ctl03%24dateLotteryDraw%24dateHiddenField=21%2F10%2F2012%200%3A00%3A00&ctl00%24bodyCenterContentPlaceHolder%24periodDateGridView%24ctl04%24dateLotteryDraw%24dateHiddenField=20%2F10%2F2012%200%3A00%3A00&ctl00%24bodyCenterContentPlaceHolder%24periodDateGridView%24ctl05%24dateLotteryDraw%24dateHiddenField=19%2F10%2F2012%200%3A00%3A00&ctl00%24bodyCenterContentPlaceHolder%24periodDateGridView%24ctl06%24dateLotteryDraw%24dateHiddenField=18%2F10%2F2012%200%3A00%3A00&ctl00%24bodyCenterContentPlaceHolder%24periodDateGridView%24ctl07%24dateLotteryDraw%24dateHiddenField=17%2F10%2F2012%200%3A00%3A00&ctl00%24bodyCenterContentPlaceHolder%24periodDateGridView%24ctl08%24dateLotteryDraw%24dateHiddenField=16%2F10%2F2012%200%3A00%3A00&__EVENTTARGET=ctl00%24bodyCenterContentPlaceHolder%24periodDateGridView&__EVENTARGUMENT=Page%242

for the second page and changes probably on every visit...


By the way, with my internet tools, you can get that postdata with a single line:

Code: [Select]
process(page, 'form(//*:form, ''__EVENTTARGET=ctl00$bodyCenterContentPlaceHolder$periodDateGridView&__EVENTARGUMENT=Page$'+inttostr(p)+''').post').toString;

And the entire program, printing all lottery numbers, one table row / line, becomes

Code: [Select]
program adv;

{$mode objfpc}{$H+}

uses Interfaces, simpleinternet, sysutils;

var
  page: String;
  p: Integer;
  x: IXQValue;
  postdata: String;
begin
  page := httpRequest('http://wnk.cc/default.aspx');
  for p := 2 to 5 do begin
    writeln('=========');
    for x in process(page, '//*:table[@id="drawTable"]/*:tr/string-join(*:td, " ")') do
      writeln(x.tostring);
    if p = 5 then exit;
    postdata := process(page, 'form(//*:form, ''__EVENTTARGET=ctl00$bodyCenterContentPlaceHolder$periodDateGridView&__EVENTARGUMENT=Page$'+inttostr(p)+''').post').toString;
    page := httpRequest('http://wnk.cc/default.aspx', postdata);
  end;

end.




(but that is with the unpublished, new interface. The published, old does  not need the *: and .toString, but also does not have the for..in loop, so it would need some ugly class creation)

Middlecope

  • Jr. Member
  • **
  • Posts: 72
Re: Synapse POST
« Reply #6 on: October 25, 2012, 02:40:02 pm »
Dear BeniBela,
From the link I can see that it wants to execute a javascript.
If that is not possible with Synapse I will try out the internettools.zip from your website
Thanks

 

TinyPortal © 2005-2018