Results 1 to 5 of 5

Thread: visit_url doesn't seem to return any data when visiting Port Beginning

  1. #1
    Senior Member
    Join Date
    Dec 2008
    Posts
    586

    Default visit_url doesn't seem to return any data when visiting Port Beginning

    I am trying to write a small script to farm FunPoints, and in doing so I want to examine the various choices I get at various point during the journey through PirateRealm.

    So far I have this snippet, but when I look at the file in my data folder after running it, it is empty although I have entered the Port Beginning choiceadventure.

    Is there a reason visit_url doesn't return the html for the adventure, and is there a way I can circumvent this?

    HTML Code:
    void main() {
        string[int] s;
    
        if (item_amount($item[PirateRealm eyepatch]) <= 0) {
            visit_url("place.php?whichplace=realm_pirate&action=pr_port");
        }
        
        if (item_amount($item[PirateRealm eyepatch]) > 0) {
            if (outfit("PirateRealm")) {
                s[1] = visit_url("place.php?whichplace=realm_pirate&action=pr_port");
            }
        }
        
        map_to_file(s, "test10.txt");
    }
    -edit- Oh, unless I already wore the eyepatch when running the script, that may have been the reason... In that case, please disregard the thread, and I guess I'll give it another go tomorrow...

  2. #2
    Senior Member ckb's Avatar
    Join Date
    Mar 2006
    Posts
    890

    Default

    try this next time you want to debug:
    Code:
    print(visit_url("place.php?whichplace=realm_pirate&action=pr_port"));

  3. #3
    Developer
    Join Date
    Apr 2006
    Posts
    941

    Default

    You may need to send a POST request instead of GET, try passing true for the second parameter: https://wiki.kolmafia.us/index.php?title=Visit_url

  4. #4
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    11,715

    Default

    That's actually the default if only give one parameter.

    Code:
    	public static Value visit_url( Interpreter interpreter, final Value string )
    	{
    		return RuntimeLibrary.visit_url( interpreter, string.toString(), true, false );
    	}
    Yesterday I had the thought that maybe he needed to send a GET - by using "false" as the second parameter - but when I tried

    Code:
    ash visit_url("place.php?whichplace=realm_pirate&action=pr_port")
    (i.e. with POST ) in the gCLI, I got the expected HTML from KoL.

  5. #5
    Junior Member
    Join Date
    Dec 2010
    Posts
    3

    Default

    I am trying to write a small script to farm FunPoints
    Originally Posted by ereinion View Post
    Hello - I'm trying to do the same at the moment too - have you managed to track grub/grog/glue/gold in your script? I can't see an easy way of doing it (unless there's a kol page I can parse that I haven't found, or something within mafia itself).

    Edit 2019/06/14:

    I've managed to achieve it with the following (excuse my poor regex):
    Code:
    int [string] getStats()
    {
        matcher pirateMatcher = create_matcher("<b>G.{3}:<\/b><\/td><td class=small>(.*?)<\/td>", visit_url("charpane.php"));
    
        int [string] pirateStats;
    
        pirateStats["guns"] = pirateMatcher.find() ? pirateMatcher.group(1).to_int() : -1;
        pirateStats["grub"] = pirateMatcher.find() ? pirateMatcher.group(1).to_int() : -1;
        pirateStats["grog"] = pirateMatcher.find() ? pirateMatcher.group(1).to_int() : -1;
        pirateStats["glue"] = pirateMatcher.find() ? pirateMatcher.group(1).to_int() : -1;
        pirateStats["gold"] = pirateMatcher.find() ? pirateMatcher.group(1).to_int() : -1;
    
        return pirateStats;
    }
    Last edited by damion117; 06-14-2019 at 07:09 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •