Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Re : How can I load these twitter URLs that load normally in my browser, but not when I try to access them with processing?

$
0
0

Ok, i got it. I suspected that I needed to pretend somehow I was "a real browser", so I looked for ways to do this. Man, it was difficult, but finally got it working. Here is one example of the code I came up with. I have another version in JAVA. Hah, I'm learning a lot. :)



  1. import processing.net.*;

    String data;
    Client c;
    String hostvar;
    String getReq;


    void setup() {

    hostvar = "t.co";
    getReq = "/L9n4hVDGbp";

    c = new Client(this, hostvar, 80); // Connect to server on port 80

    //c.write("GET / HTTP/1.1\r\n"); // Use the HTTP "GET" command to ask for a Web page

    c.write("GET "+ getReq + " HTTP/1.1\r\n");
      c.write("Host:" + hostvar + "\r\n"); // Host to which we are directing
      c.write("User-Agent: Opera/9.80 (Windows NT 6.1; WOW64) Presto/2.12.388 Version/12.12; en-US; rv:1.9.0.7) Gecko/2009021906 Firefox/3.0.7\n"); //this does the magic
    c.write("\r\n");
    }

    void draw() {
    if (c.available() > 0) { // If there's incoming data from the client...
    data = c.readString(); // ...then grab it and print it
    println(data);
    }
    }

---
For if reason has once undoubted right on its side, it will not allow itself to be confined to set limits, by vague recommendations of moderation. -Immanuel Kant

Viewing all articles
Browse latest Browse all 1768

Trending Articles