How do HTTP request?

Asked

Viewed 789 times

4

I would like to make an HTTP request to my college server by mimicking the requests sent by the browser so I can log in and check my notes.

I already have experience with mobile development, my intention is in the future to develop an App for access notes, absences, college courses.

How can I make these requests on Node.js?

  • Guy checks if they have an API for programmers to use (usually not have), or tries to use CURL, take a look at this tutorial

  • @Jonatanribeirodossantos , this really seems to be what I look for, however I have no knowledge of php. to run a php I need to have a server running locally ?

  • Friend what language you’re using?

  • I know very well python and javascript...

  • 1

    If you want to use java, look for the class java.net.HttpURLConnection.

  • Dude, if your javascript skills try to do in nodejs, or if you know Python take a look at how to use CURL in python, it shouldn’t be the end of the world.

  • Python URL does not exist in windows 64 bits

  • Hello, welcome to [en.so]! I made a small edition in the question to try to make it clearer. However, it would be better to specify in which language or platform. I tagged android Just because you said you have some experience in mobile programming. But please edit your question by specifying better with which technology you want to make the requests. Hug!

  • Python you can use mechanize, for example...

  • 3

    I saw that the tag was changed to javascript. If you want to make a script to run in the browser it will most likely not be possible to make HTTP requests to your college server, as the standard security policy prevents Ajax requests between different domains. It would be possible to do this with Node.js, but then it would involve all the environment configuration. Maybe it’s better to stay with Python. But, if you want to do this in the future on Android, my suggestion is already do it in Java to facilitate.

  • I agree with what @utluiz said (except with the part that doing Java is easier than Node.js + Javascript, hehehehe).

  • A friend advised me to use Node js, since what I want to do is like a Mining data, because I am trying to receive information from a server without the browser... I think I will try to use Node, if anyone has any advice I thank you.

  • So, the Node fits perfectly for this, does not run in the browser. You can even use a browser headless (no graphical interface) like phantomjs, so you can mine data even from ajax-based websites (which you wouldn’t normally be able to).

  • @bfavaretto Not that Java is easier. It’s easier to pass a Java code to Android just because it’s Java too (or almost that). ;)

  • Ah, I didn’t realize I had Android in play. In this case he will have to swallow Java even (hehehe x 2). @utluiz

  • Can be done with Zombiejs which is a framework for testing web pages simulating a browser and Node has Phonegap which creates HTML5+CSS+JS-based hybrid applications for the case you want for mobile app

Show 11 more comments

1 answer

3


There are some tools for this type of technique (called Web Scraping). In Javascript some alternatives are:

  • mechanize-js an adaptation of the famous Mechanize library (originally available in Perl but which today has support in several languages such as Python, Ruby, JS, etc);
  • Zombie JS: a browser with no interface capable of completely emulating the interaction with a web page, in exactly the same way that would occur with a conventional browser).

Note that building an application on top of this type of interaction as long as possible is not the ideal strategy - Depending on the visualization layer of a system to extract data is a fairly unstable technique and can break at the expense of the simplest modifications by this system. The best option would be to use a stable API with versioning and documentation; but this is not always possible.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.