-2

I am trying to click on a CSS button via CURL/WGET, however so far I am having no luck. The exact link location for the CSS button is a dynamic URI - for example:

domain.com/some/page?thing=1

Still when you access that page via curl/wget it does not trigger the action. There is a CSS selector which I need to access somehow. I found this:

http://codeception.com/docs/modules/PhpBrowser

However it requires installing additional software which is not an option. I need something that would work with curl/wget or perhaps a sample PHP script. I tried providing the following argument to wget:

--header="selector: some-selector"

However it does not achieve the desired result.

Here is some more information from the comment, so that it is easier to see:

I've got the HTTP headers and tried to replicate them but with no luck. They are too long so I uploaded example headers to:

http://textuploader.com/oopa

Could anyone provide example script/command that could be used to achieve the above?

The action is not triggered by accessing the url - it requires you to click on a button. I have provided HTTP headers in my previous command. Here is what the exact button looks like when inspected:

<div style="margin-bottom:15px;">

  <a style="display:block; width:350px" href="http://www.test.com/hos/6/42?game=1" id="game-one">
    <img src="http://www.test.com/images/thumbs_up.jpg" width="24" height="24" />
                           Sample Text
  </a>

</div>

So basically I need to activate the game-one selector some how - simulate a click on that button via a script. The PHPBrowser that I mentioned above seems to offer this functionality, however I cannot install it as it requires additional software which is not an option in this case.

6
  • there's no "buttons" in http. there's just urls. curl would have to end up replicating exactly whatever request(s) the original html/js code are doing. Commented Oct 8, 2014 at 20:37
  • I've got the HTTP headers and tried to replicate them but with no luck. They are too long so I uploaded example headers to: textuploader.com/oopa Could anyone provide example script/command that could be used to achieve the above? Thanks Commented Oct 8, 2014 at 20:45
  • What do you mean by click on a CSS button via CURL/WGET? Any thing to do with CSS here? I don't think so. Commented Oct 8, 2014 at 20:48
  • What do you mean when you say "CSS button"? Can you provide a link to the page with the button? Commented Oct 8, 2014 at 20:49
  • As others have said you will need to use curl or wget to "post" the button url... You're basically faking a form submit or action but you can only use the relevant url to complete the action. Commented Oct 8, 2014 at 20:55

2 Answers 2

1

In a comment below your question, you gave the following HTML for the "CSS button."

<a id="game-one" href="test.com/hos/6/42?game=1"; style="display:block; width:350px">

It's difficult to tell from this anchor alone, but it appears that you have a plain ol' link. In other words, to click this button is to click a link, which is to make an HTTP GET request to test.com/hos/6/42?game=1 and render a page. If this is the case, then using curl or wget to request test.com/hos/6/42?game=1 is effectively mimicking that button click (assuming cookies don't matter).

It's also possible that there is some Javascript code waiting to receive a click event from id="game-one", but I can't tell for sure without looking at the page with the "CSS button." But if that's the case, consider triggering a click event using Javascript. See How to simulate a click with JavaScript? for a plain Javascript implementation or Simulating Button click in javascript for a JQuery implementation.

Sign up to request clarification or add additional context in comments.

2 Comments

Unfortunately accessing the link does not get the job done - not via web browser, and not via CURL either - it simply accesses the web page on which the button is located, however it does not trigger the button's action.. I cannot provide the exact page, as it is currently in test period and it is not publicly accessible - that is why I am providing only sample information, sill I think that the information should be sufficient if the above is possible... I will update my original reply with more information regarding the button.
When you say "button's action," are you saying that there is some Javascript code executing in response to a click event?
1

Thanks for the help everyone.

I was actually able to figure this out - it is possible via CURL. It appears that it was necessary to add referer set for the previous page, so in order to access the dynamic URI and trigger the action I used the following CURL:

curl --head --referer 'http://www.test.com/hos/6/42' http://www.test.com/hos/6/42?game=1

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.