How to open a link, fill data then click a button with no browser?












0















What I need is to open a web page with a link fill some textbox with my data, click in any button and then read the data of the page in C#.
For example :



Open (www.google.es) then fill the search box with "stackOverFlow", click on the search button and then read the results.



I've been looking and I think I can read the data with HttpClient but I have no clue about how to proceed with the other part.



Edit: Actually using a .net Framework console aplicattion but I can change this to an MVC app or a Winform app










share|improve this question




















  • 1





    Is your example remotly correct? If so, that isn't necessary - since you could just simply build the URL yourself with the search query. So, instead of going to "google.es" and enter stuff into TextBox just build the URL and navigate to the URL directly "google.es/search?q=stackOverFlow"

    – Rand Random
    Nov 14 '18 at 8:44








  • 1





    Unfortunately no, is just an example. I would like to do a generic methods.

    – Fran
    Nov 14 '18 at 8:53











  • Submitting a form executes a POST request. You don't need a browser to do that. You can use HttpClient.PostAsync to send the same request. You can use a debugging proxy like Fiddler to see what that form actually sends to the server and create an equivalent request

    – Panagiotis Kanavos
    Nov 14 '18 at 9:06











  • The response of PostAsync will contain the new page, which you can parse to extract the data you want. HTML parsing isn't trivial though. If you want to extract the contents of specified form fields or named elements you may be able to use regex. Otherwise you'll need a parser like HtmlAgility

    – Panagiotis Kanavos
    Nov 14 '18 at 9:09











  • Rand Random gave a good solution for Google. A generic solution (all pages) may be impossible. You can't always find the form to POST your search to, without executing the javascript ! Consider using CefSharp, which can provide a browser in a form.. then use Wolinski's answer below after the page is loaded. See: myget.org/feed/cefsharp/package/nuget/CefSharp.WinForms

    – Goodies
    Nov 14 '18 at 9:45


















0















What I need is to open a web page with a link fill some textbox with my data, click in any button and then read the data of the page in C#.
For example :



Open (www.google.es) then fill the search box with "stackOverFlow", click on the search button and then read the results.



I've been looking and I think I can read the data with HttpClient but I have no clue about how to proceed with the other part.



Edit: Actually using a .net Framework console aplicattion but I can change this to an MVC app or a Winform app










share|improve this question




















  • 1





    Is your example remotly correct? If so, that isn't necessary - since you could just simply build the URL yourself with the search query. So, instead of going to "google.es" and enter stuff into TextBox just build the URL and navigate to the URL directly "google.es/search?q=stackOverFlow"

    – Rand Random
    Nov 14 '18 at 8:44








  • 1





    Unfortunately no, is just an example. I would like to do a generic methods.

    – Fran
    Nov 14 '18 at 8:53











  • Submitting a form executes a POST request. You don't need a browser to do that. You can use HttpClient.PostAsync to send the same request. You can use a debugging proxy like Fiddler to see what that form actually sends to the server and create an equivalent request

    – Panagiotis Kanavos
    Nov 14 '18 at 9:06











  • The response of PostAsync will contain the new page, which you can parse to extract the data you want. HTML parsing isn't trivial though. If you want to extract the contents of specified form fields or named elements you may be able to use regex. Otherwise you'll need a parser like HtmlAgility

    – Panagiotis Kanavos
    Nov 14 '18 at 9:09











  • Rand Random gave a good solution for Google. A generic solution (all pages) may be impossible. You can't always find the form to POST your search to, without executing the javascript ! Consider using CefSharp, which can provide a browser in a form.. then use Wolinski's answer below after the page is loaded. See: myget.org/feed/cefsharp/package/nuget/CefSharp.WinForms

    – Goodies
    Nov 14 '18 at 9:45
















0












0








0








What I need is to open a web page with a link fill some textbox with my data, click in any button and then read the data of the page in C#.
For example :



Open (www.google.es) then fill the search box with "stackOverFlow", click on the search button and then read the results.



I've been looking and I think I can read the data with HttpClient but I have no clue about how to proceed with the other part.



Edit: Actually using a .net Framework console aplicattion but I can change this to an MVC app or a Winform app










share|improve this question
















What I need is to open a web page with a link fill some textbox with my data, click in any button and then read the data of the page in C#.
For example :



Open (www.google.es) then fill the search box with "stackOverFlow", click on the search button and then read the results.



I've been looking and I think I can read the data with HttpClient but I have no clue about how to proceed with the other part.



Edit: Actually using a .net Framework console aplicattion but I can change this to an MVC app or a Winform app







c# .net web






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 8:26







Fran

















asked Nov 14 '18 at 8:19









Fran Fran

558




558








  • 1





    Is your example remotly correct? If so, that isn't necessary - since you could just simply build the URL yourself with the search query. So, instead of going to "google.es" and enter stuff into TextBox just build the URL and navigate to the URL directly "google.es/search?q=stackOverFlow"

    – Rand Random
    Nov 14 '18 at 8:44








  • 1





    Unfortunately no, is just an example. I would like to do a generic methods.

    – Fran
    Nov 14 '18 at 8:53











  • Submitting a form executes a POST request. You don't need a browser to do that. You can use HttpClient.PostAsync to send the same request. You can use a debugging proxy like Fiddler to see what that form actually sends to the server and create an equivalent request

    – Panagiotis Kanavos
    Nov 14 '18 at 9:06











  • The response of PostAsync will contain the new page, which you can parse to extract the data you want. HTML parsing isn't trivial though. If you want to extract the contents of specified form fields or named elements you may be able to use regex. Otherwise you'll need a parser like HtmlAgility

    – Panagiotis Kanavos
    Nov 14 '18 at 9:09











  • Rand Random gave a good solution for Google. A generic solution (all pages) may be impossible. You can't always find the form to POST your search to, without executing the javascript ! Consider using CefSharp, which can provide a browser in a form.. then use Wolinski's answer below after the page is loaded. See: myget.org/feed/cefsharp/package/nuget/CefSharp.WinForms

    – Goodies
    Nov 14 '18 at 9:45
















  • 1





    Is your example remotly correct? If so, that isn't necessary - since you could just simply build the URL yourself with the search query. So, instead of going to "google.es" and enter stuff into TextBox just build the URL and navigate to the URL directly "google.es/search?q=stackOverFlow"

    – Rand Random
    Nov 14 '18 at 8:44








  • 1





    Unfortunately no, is just an example. I would like to do a generic methods.

    – Fran
    Nov 14 '18 at 8:53











  • Submitting a form executes a POST request. You don't need a browser to do that. You can use HttpClient.PostAsync to send the same request. You can use a debugging proxy like Fiddler to see what that form actually sends to the server and create an equivalent request

    – Panagiotis Kanavos
    Nov 14 '18 at 9:06











  • The response of PostAsync will contain the new page, which you can parse to extract the data you want. HTML parsing isn't trivial though. If you want to extract the contents of specified form fields or named elements you may be able to use regex. Otherwise you'll need a parser like HtmlAgility

    – Panagiotis Kanavos
    Nov 14 '18 at 9:09











  • Rand Random gave a good solution for Google. A generic solution (all pages) may be impossible. You can't always find the form to POST your search to, without executing the javascript ! Consider using CefSharp, which can provide a browser in a form.. then use Wolinski's answer below after the page is loaded. See: myget.org/feed/cefsharp/package/nuget/CefSharp.WinForms

    – Goodies
    Nov 14 '18 at 9:45










1




1





Is your example remotly correct? If so, that isn't necessary - since you could just simply build the URL yourself with the search query. So, instead of going to "google.es" and enter stuff into TextBox just build the URL and navigate to the URL directly "google.es/search?q=stackOverFlow"

– Rand Random
Nov 14 '18 at 8:44







Is your example remotly correct? If so, that isn't necessary - since you could just simply build the URL yourself with the search query. So, instead of going to "google.es" and enter stuff into TextBox just build the URL and navigate to the URL directly "google.es/search?q=stackOverFlow"

– Rand Random
Nov 14 '18 at 8:44






1




1





Unfortunately no, is just an example. I would like to do a generic methods.

– Fran
Nov 14 '18 at 8:53





Unfortunately no, is just an example. I would like to do a generic methods.

– Fran
Nov 14 '18 at 8:53













Submitting a form executes a POST request. You don't need a browser to do that. You can use HttpClient.PostAsync to send the same request. You can use a debugging proxy like Fiddler to see what that form actually sends to the server and create an equivalent request

– Panagiotis Kanavos
Nov 14 '18 at 9:06





Submitting a form executes a POST request. You don't need a browser to do that. You can use HttpClient.PostAsync to send the same request. You can use a debugging proxy like Fiddler to see what that form actually sends to the server and create an equivalent request

– Panagiotis Kanavos
Nov 14 '18 at 9:06













The response of PostAsync will contain the new page, which you can parse to extract the data you want. HTML parsing isn't trivial though. If you want to extract the contents of specified form fields or named elements you may be able to use regex. Otherwise you'll need a parser like HtmlAgility

– Panagiotis Kanavos
Nov 14 '18 at 9:09





The response of PostAsync will contain the new page, which you can parse to extract the data you want. HTML parsing isn't trivial though. If you want to extract the contents of specified form fields or named elements you may be able to use regex. Otherwise you'll need a parser like HtmlAgility

– Panagiotis Kanavos
Nov 14 '18 at 9:09













Rand Random gave a good solution for Google. A generic solution (all pages) may be impossible. You can't always find the form to POST your search to, without executing the javascript ! Consider using CefSharp, which can provide a browser in a form.. then use Wolinski's answer below after the page is loaded. See: myget.org/feed/cefsharp/package/nuget/CefSharp.WinForms

– Goodies
Nov 14 '18 at 9:45







Rand Random gave a good solution for Google. A generic solution (all pages) may be impossible. You can't always find the form to POST your search to, without executing the javascript ! Consider using CefSharp, which can provide a browser in a form.. then use Wolinski's answer below after the page is loaded. See: myget.org/feed/cefsharp/package/nuget/CefSharp.WinForms

– Goodies
Nov 14 '18 at 9:45














2 Answers
2






active

oldest

votes


















0














You should be able to type input by calling script:



document.getElementById("Input").value = "My value";


and then post it by calling script from question below or simulate button clink (if you are not sure that button do post)



JavaScript post request like a form submit



Simulating Button click in javascript






share|improve this answer































    0














    If you are trying to create a custom search and show result in your own application, you will need to find the implementation of rest API of that search provider. To get started, luckily google provides that.



    follow the link to get started:
    https://developers.google.com/custom-search/v1/overview






    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53295705%2fhow-to-open-a-link-fill-data-then-click-a-button-with-no-browser%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      You should be able to type input by calling script:



      document.getElementById("Input").value = "My value";


      and then post it by calling script from question below or simulate button clink (if you are not sure that button do post)



      JavaScript post request like a form submit



      Simulating Button click in javascript






      share|improve this answer




























        0














        You should be able to type input by calling script:



        document.getElementById("Input").value = "My value";


        and then post it by calling script from question below or simulate button clink (if you are not sure that button do post)



        JavaScript post request like a form submit



        Simulating Button click in javascript






        share|improve this answer


























          0












          0








          0







          You should be able to type input by calling script:



          document.getElementById("Input").value = "My value";


          and then post it by calling script from question below or simulate button clink (if you are not sure that button do post)



          JavaScript post request like a form submit



          Simulating Button click in javascript






          share|improve this answer













          You should be able to type input by calling script:



          document.getElementById("Input").value = "My value";


          and then post it by calling script from question below or simulate button clink (if you are not sure that button do post)



          JavaScript post request like a form submit



          Simulating Button click in javascript







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 14 '18 at 8:59









          Michał WolińskiMichał Woliński

          15412




          15412

























              0














              If you are trying to create a custom search and show result in your own application, you will need to find the implementation of rest API of that search provider. To get started, luckily google provides that.



              follow the link to get started:
              https://developers.google.com/custom-search/v1/overview






              share|improve this answer




























                0














                If you are trying to create a custom search and show result in your own application, you will need to find the implementation of rest API of that search provider. To get started, luckily google provides that.



                follow the link to get started:
                https://developers.google.com/custom-search/v1/overview






                share|improve this answer


























                  0












                  0








                  0







                  If you are trying to create a custom search and show result in your own application, you will need to find the implementation of rest API of that search provider. To get started, luckily google provides that.



                  follow the link to get started:
                  https://developers.google.com/custom-search/v1/overview






                  share|improve this answer













                  If you are trying to create a custom search and show result in your own application, you will need to find the implementation of rest API of that search provider. To get started, luckily google provides that.



                  follow the link to get started:
                  https://developers.google.com/custom-search/v1/overview







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 14 '18 at 9:04









                  Tazbir BhuiyanTazbir Bhuiyan

                  1,3421424




                  1,3421424






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53295705%2fhow-to-open-a-link-fill-data-then-click-a-button-with-no-browser%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      List item for chat from Array inside array React Native

                      Thiostrepton

                      Caerphilly