I am trying to scrap a web, On the main page, there are a few option buttons and then an ACCEPT button, and RESET button, when ACCEPT button is pressed after selecting appropriate option, new contents are displayed,
my question is, how can I sent a request through curl, when i inspect the ACCEPT button a JavaScript function is initiated, like
JavaScript:someFunction();
Can somebody guide me what should I do? how can I do it via curl and php? Or I should learn some new technique for this, my guess is, the ACCEPT button is sending an AJAX CALL,
guide me please
You need to call that ajax url using cURL and also set those desired variables along with proper values which are set after clicking that button. You can check cURL form posts.
Thanks.
Are you trying to simply click the button and submit the form? If that's the case, you can do that with plain javascript:
document.getElementById('acceptButtonId').click();
When the button clicked, you can post the data into the same page. Then with the variables you posted, you use cURL.
Related
I want to put something extra information which is dynamic on get request URL right after user click submit button and right before it sent request to server.
Basically, I want to hold request until modify request URL right before it send to server.
I could not find any solution from any other site.. I tried to use jquery due to do that I described above ..
If anything is unclear please leave comment so that I can change
Does it have to be GET? You can add a hidden input in your form and it will be POST when you press the submit button.
In an answer because I can't put comments yet.
Ask questions in comments here, I will update answer accordingly
I'm trying to find a way for PHP to press the "submit" button on a PHP form on a live webpage.
I need to do this as I am unsure as towards what data is send through this form, as it is a post form and the API is closed source.
Is there anyway to send a jQuery like click command to a live webpage through PHP at all?
Nothing needs to be retrieved from this form, only needs to have pressed the button correctly.
EDIT
More context:
Yes, the site is 3rd party (this is why I can't simply look up something on any API documentation), the program is downloading a gallery of images through the in-site gallery archiver. Previously the URL for this gallery's archive was stored on a simple popup window page's source. Now however you must confirm it first the page reloads (after a form submits through POST) onto the same page (archiver.php) and the download starts. This reloaded page contains the URL of the file. Nothing is submitted beyond the users confirmation to the download manually, perhaps something in the back end is sent upon this, I don't know.
EDIT 2
I've fixed this by figuring out what the form submits.
I think it is not possible to click a button on another page with php or jquery.
But you can analyse the form and find out the destination URL and send a own request. If it is GET it should look like this: myhomepage.com?id=1&name=foo&password=hello123
you have to use jQuery or javaScript For pressing submit button on live page dynamically. PHP is server side script and from is client side so its not possible. but if you want to read data from live webpage than you have to use cURL or file_get content
I am wondering if it is possible to to resubmit a form with a button click that calls up a javascript command.
So this is basically what I'm trying to do -
page 1: form; action = page2.php
page 2: generate a randomized list according to parameters set by page 1
I would like to place a button on page 2 so that on click, it would be as if the user has hit F5, and a new list would be generated with the same parameters.
I found a lot of help on Google with people trying NOT to get this to happen, but I'm not sure how to actually get it to happen.....
Thank you!
You could use location.reload(true); to refresh the page.
<button onclick="location.reload(true);">refresh</button>
you only need to use. location.reload() instead of location.reload(true). since this will not disable caching for the reload but using true as the parameter will.
here is the reference. How to refresh a page in jquery?
EDIT: why not just use hidden input field and preserve the values and fetch it anytime you want to?
Is it possible to update the value of a variable from another page using JavaScript?
or
Is it possible to do this using form on submit, just update the other page, but remain on the page on which the form is located?
I think what you are searching for is AJAX (Asynchronous JavaScript and XML) which performs a get or post action and waiting for the result of the server. This makes it possible to submit a form without jumping to the page.
Have a look at this
Or if you use JQuery this
You can simply send all the data to be updated via Ajax and simply get the response on the current page You are in.
I basically have to do a update of a record. I have a set of controls like textbox, list box, radio button etc. Then i have a button on click of which i need to carry all the updated data into mysql database with a ajax request without page refresh.
I am using the php with codeigniter as my serverside code. On client side i am able to send the ajax request like
$(document).ready(function(){
$('#users_menu').click(
function(){
$('#tempdiv').load('http://localhost//web1/index.php/c1',null);
}
);
});
In the above code the request is placed to a server side php page where i am not able to read the values of the control values (values of textbox, listbox etc). Now this means i should be sending the list with the request. But i am not aware of how to send this request.
Please help me with some details of how to send the list of values or is it possible to read the vaules some how in the serverside php code. For your information i am using codeigniter with my php. Any kind of help is appreciated.
Thanks and Regards
VinodT.
You need to use jQuery .post() function and specify the data to send, see here jQuery.post
You will end up needing to do something similiar to this.
$.post("http://localhost//web1/index.php/c1", $("#testform").serialize());