How do I create content programatically? In WordPress I can use wp_insert_post() to create content programatically.

Is there any similar function available for Drupal 7, that will allow me to insert posts (and pages) into the database programatically?
you can create a custom function to create a node. 

function create_my_node() {
  $node = new stdClass();
  $node-&gt;type = 'your content type';
  node_object_prepare($node);

  $node-&gt;title = "your title";
  $node-&gt;language = LANGUAGE_NONE;
  global $user;

  $newnode-&gt;uid = $user-&gt;uid;
  $newnode-&gt;name = $user-&gt;name;
  $newnode-&gt;status = 1;     // 1 means published
  $newnode-&gt;promote = 0;
  node_save($node);
}