Thread: Send HTML text to a variable and POST to a webbsite?

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    8

    Send HTML text to a variable and POST to a webbsite?

    Hello. New here.

    I have a question. How do I "download" HTML text and send it to a variable?

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    int main(void)
    {
      int html_text;
      html_text <-- get HTML text form e.g google.com
      printf(html_text);
      system("PAUSE");	
      return 0;
    }
    My second question is almust the same.

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    int main(void)
    {
      int send;
      scanf("%d", &send);  
      URL google <-- send;
      system("PAUSE");	
      return 0;
    }
    It will be like urllib2 as in python.

    Code:
    import urllib, urllib2, cookielib  
    
    username = 'myuser'  
    password = 'mypassword'  
    
    cj = cookielib.CookieJar()  
    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))  
    login_data = urllib.urlencode({'username' : username, 'j_password' : password})  
    opener.open('http://www.example.com/login.php', login_data)  
    resp = opener.open('http://www.example.com/hiddenpage.php')  
    resp.read()
    Thx for anwsers.

    P.S it must have a cookie function so I cannot loggout automatic.
    Last edited by heretic; 04-29-2011 at 04:34 AM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,667
    libcurl - the multiprotocol file transfer library
    Has some get/post methods which should make things a little easier.


    I hope that wasn't your real password...
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Apr 2011
    Posts
    8
    Here i found some exemples. But do they cost money?

    C HTTP POST

    Or is it only for Windows?

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,667
    Yes, those cost money.

    LibCurl is free.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Apr 2011
    Posts
    8
    Quote Originally Posted by Salem View Post
    Yes, those cost money.

    LibCurl is free.
    ...and its also...SWE.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Open default browser and send an HTTP request (POST Method)
    By dit6a9 in forum Windows Programming
    Replies: 3
    Last Post: 09-03-2005, 01:31 AM
  2. How can I send a text string to an edit control
    By marc74 in forum Windows Programming
    Replies: 5
    Last Post: 01-06-2005, 10:14 PM
  3. Help: send text to printer.
    By FaridEsna in forum C Programming
    Replies: 1
    Last Post: 10-16-2002, 10:09 AM
  4. Replies: 14
    Last Post: 05-25-2002, 05:46 PM
  5. Winsock exe send html to IE
    By (TNT) in forum Windows Programming
    Replies: 1
    Last Post: 12-23-2001, 07:00 PM