Jacq Posted May 17, 2013 Share Posted May 17, 2013 Welcome I would like to create a link URL or script that will be assigned to a button on my website, but when pressed will open the outside website and pressed button on this site. This button on the outside website is not assigned to link button is assigned to function and this is a problem for me. I made a url link that is writing on the outside website text "username" in form http://www.weeb.tv/account/login&username=username I want to do something like this but instead of typing I want to press the button using the url link or script. This is a sample page and button code Page: http://www.tvmuse.eu/tv-shows/Grimm_27159/season_2/episode_20/ Button code: <button class="btn btn_light" id="btn_wlist" onclick="sendAction('6')"><span><em class="i_subscribe"> </em>Add TV Show to Watchlist</span></button> Is it possible to click the button using the id or something. Please help Link to comment https://forums.phpfreaks.com/topic/278113-go-to-and-click-button/ Share on other sites More sharing options...
Jacq Posted May 20, 2013 Author Share Posted May 20, 2013 (edited) My question is how to get the html code of for example www.example.com and then read the value of one line using the id.<input type="hidden" name="elementId" value="7548" id="elementId">So I want to get the html code of website to a variable and then I want to read the value of a single line in the whole code using the id in this case I want numer (7548) and then insert this numer to the variable and then i want connect link with variablewww.example.com/zwhere {z} is a variable in this case numer 7548 then I want create variable using this to parts www.example.com/ and z I want the whole code to be activated when I press button.Please help Edited May 20, 2013 by Jacq Link to comment https://forums.phpfreaks.com/topic/278113-go-to-and-click-button/#findComment-1431157 Share on other sites More sharing options...
Eiseth Posted May 20, 2013 Share Posted May 20, 2013 My question is how to get the html code of for example www.example.com and then read the value of one line using the id. <input type="hidden" name="elementId" value="7548" id="elementId"> So I want to get the html code of website to a variable and then I want to read the value of a single line in the whole code using the id in this case I want numer (7548) and then insert this numer to the variable and then i want connect link with variable www.example.com/z where {z} is a variable in this case numer 7548 then I want create variable using this to parts www.example.com/ and z I want the whole code to be activated when I press button. Please help Are you trying to parse an html from other live site? If so, try using DOMDocument and DOMXPath to parse html and get the element that you want <?php // Hide errors $oldSetting = libxml_use_internal_errors( true ); libxml_clear_errors(); // Instantiate domdocument so we can fetch the html $dom = new DOMDocument(); $dom->loadHTMLFile('http://forums.phpfreaks.com/'); // put your website to scrape here // Instantiate domxpath to perform query so we can search an html element by their ids/classname. $xpath = new DOMXPath($dom); // This query will find all the <input type="hidden"> // use "//input[@id='elementid']" if you want to search by their id $entries = $xpath->query("//input[@type='hidden']"); // Loop through each result then get the "value" attribute foreach ($entries as $entry) { echo $entry->getAttribute('value') . '<br>'; } libxml_clear_errors(); libxml_use_internal_errors( $oldSetting ); Link to comment https://forums.phpfreaks.com/topic/278113-go-to-and-click-button/#findComment-1431204 Share on other sites More sharing options...
Jacq Posted June 27, 2013 Author Share Posted June 27, 2013 How to add this numer result to a link. So I want to get the html code of website to a variable and then I want to read the value of a single line in the whole code using the id in this case I want numer (7548) and then insert this numer to the variable and then i want connect link with variablewww.example.com/zwhere {z} is a variable in this case numer 7548 then I want create variable using this to parts www.example.com/ and z I want the whole code to be activated when I press button.Please help Link to comment https://forums.phpfreaks.com/topic/278113-go-to-and-click-button/#findComment-1438242 Share on other sites More sharing options...
Jacq Posted June 29, 2013 Author Share Posted June 29, 2013 Anybody? Link to comment https://forums.phpfreaks.com/topic/278113-go-to-and-click-button/#findComment-1438465 Share on other sites More sharing options...
ginerjm Posted June 29, 2013 Share Posted June 29, 2013 Have no idea what you are saying. Link to comment https://forums.phpfreaks.com/topic/278113-go-to-and-click-button/#findComment-1438473 Share on other sites More sharing options...
Jacq Posted June 30, 2013 Author Share Posted June 30, 2013 Help me with this code: <?php // Hide errors $oldSetting = libxml_use_internal_errors( true ); libxml_clear_errors(); // Instantiate domdocument so we can fetch the html $dom = new DOMDocument(); $dom->loadHTMLFile('http://www.btvguide.com/Keeping-Up-with-the-Kardashians'); // put your website to scrape here // Instantiate domxpath to perform query so we can search an html element by their ids/classname. $xpath = new DOMXPath($dom); // This query will find all the <input type="hidden"> // use "//input[@id=elementid]" if you want to search by their id $entries = $xpath->query("//input[@id=elementid]"); // Loop through each result then get the "value" attribute foreach ($entries as $entry) { echo $entry->getAttribute('value') . '<br>'; } libxml_clear_errors(); libxml_use_internal_errors( $oldSetting ); echo $entry; ?> This code doesn't work. Link to comment https://forums.phpfreaks.com/topic/278113-go-to-and-click-button/#findComment-1438633 Share on other sites More sharing options...
trq Posted June 30, 2013 Share Posted June 30, 2013 This is not how you get help on a help forum. I suggest your read this: http://www.catb.org/esr/faqs/smart-questions.html and come back when you understand how to formulate a question in such a way that people will want / be able to help you. Link to comment https://forums.phpfreaks.com/topic/278113-go-to-and-click-button/#findComment-1438642 Share on other sites More sharing options...
Recommended Posts