title: How to make a bot with PHP to log in and do stuff on a website
body: <p>What I am trying to do is make a bot which would log in to a site using my account and do some work automatically (legit work of course).</p>
  
  <p>For example, there may be a post in a forum with thousands of comments separated into hundreds of pages. The post can only be viewed by registered users. I wish to find comments of a specific user there and I want a PHP bot to log in with my account, read every comment page one by one and extract comments of that specific user and display them to me.</p>
  
  <p>This was just an example of course. I can do the extraction and parsing, but I cannot seem to actually make the bot log in and move on. I am only a beginner in PHP, I have tried the following:</p>
  
  <ol>
  <li><p>Used my own form to pass post data to the login page of the site, but did not work because it kept saying invalid referer.</p></li>
  <li><p>I logged in manually and then opened my script in a new tab, but it didn't work either and it asked the bot to log in again.</p></li>
  </ol>
  
  <p>So can you please give me an idea about how to do this? Basically it needs to go to the login page, somehow type in the username and password, log in, go to a specific page, and do stuff.</p>
  
  <p>By the way, can this be done with JavaScript as well?</p>
  
  <p>Thanks.</p>