www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Phobos urllib

reply Mengu <mengukagan gmail.com> writes:
Hello everyone,

Python has a library named urllib which can be found at
http://docs.python.org/library/urllib2.html. 

Does Phobos have anything similar to this library? All I need is fetching data
from a web site.
Aug 12 2010
parent reply Mengu <mengukagan gmail.com> writes:
Mengu Wrote:

 Hello everyone,
 
 Python has a library named urllib which can be found at
http://docs.python.org/library/urllib2.html. 
 
 Does Phobos have anything similar to this library? All I need is fetching data
from a web site.
Anyone has any idea on this matter?
Aug 13 2010
next sibling parent reply Adam Ruppe <destructionator gmail.com> writes:
I've been using the curl library with a thin wrapper in D:

http://arsdnet.net/dcode/curl.d

Example use:

 dmd test.d curl.d -L-lcurl
=====
import std.stdio;
import arsd.curl;


void main() {
	writefln("%s", curl("http://arsdnet.net/dcode/curl.d"));
}
=====

That fetches the code off my site and prints it out.
Aug 13 2010
parent reply Graham Fawcett <fawcett uwindsor.ca> writes:
Hey Adam,

On Fri, 13 Aug 2010 10:21:33 -0400, Adam Ruppe wrote:

 I've been using the curl library with a thin wrapper in D:
 
 http://arsdnet.net/dcode/curl.d
 
 Example use:
 
  dmd test.d curl.d -L-lcurl
Just FYI, if you add 'pragma(lib, "curl");' to the top of your curl.d file, you shouldn't need '-L-lcurl' any more; dmd will add it automatically during linking. Best, Graham
 =====
 import std.stdio;
 import arsd.curl;
 
 
 void main() {
 	writefln("%s", curl("http://arsdnet.net/dcode/curl.d"));
 }
 =====
 
 That fetches the code off my site and prints it out.
Aug 13 2010
parent reply Adam Ruppe <destructionator gmail.com> writes:
On 8/13/10, Graham Fawcett <fawcett uwindsor.ca> wrote:
 Just FYI, if you add 'pragma(lib, "curl");' to the top of your
 curl.d file, you shouldn't need '-L-lcurl' any more; dmd will
 add it automatically during linking.
Very cool. For some reason, I thought that didn't work on linux... I must have just been doing it wrong before. Thanks!
Aug 13 2010
parent reply "Nick Sabalausky" <a a.a> writes:
"Adam Ruppe" <destructionator gmail.com> wrote in message 
news:mailman.284.1281721417.13841.digitalmars-d puremagic.com...
 On 8/13/10, Graham Fawcett <fawcett uwindsor.ca> wrote:
 Just FYI, if you add 'pragma(lib, "curl");' to the top of your
 curl.d file, you shouldn't need '-L-lcurl' any more; dmd will
 add it automatically during linking.
Very cool. For some reason, I thought that didn't work on linux... I must have just been doing it wrong before.
I had been thinking it was just a feature of "bud". Very good to know.
Aug 13 2010
parent Stanislav Blinov <blinov loniir.ru> writes:
  13.08.2010 22:27, Nick Sabalausky wrote:
 "Adam Ruppe"<destructionator gmail.com>  wrote in message
 news:mailman.284.1281721417.13841.digitalmars-d puremagic.com...
 On 8/13/10, Graham Fawcett<fawcett uwindsor.ca>  wrote:
 Just FYI, if you add 'pragma(lib, "curl");' to the top of your
 curl.d file, you shouldn't need '-L-lcurl' any more; dmd will
 add it automatically during linking.
Very cool. For some reason, I thought that didn't work on linux... I must have just been doing it wrong before.
I had been thinking it was just a feature of "bud". Very good to know.
It works well with .d files, but not with import (.di) files. Both on Windows and Linux. Maybe I miss something? --
Aug 16 2010
prev sibling parent reply Graham Fawcett <fawcett uwindsor.ca> writes:
Hi Mengu,

On Fri, 13 Aug 2010 10:15:01 -0400, Mengu wrote:

 Mengu Wrote:
 
 Hello everyone,
 
 Python has a library named urllib which can be found at
 http://docs.python.org/library/urllib2.html.
 
 Does Phobos have anything similar to this library? All I need is
 fetching data from a web site.
Anyone has any idea on this matter?
I don't think there is anything usable in Phobos at the moment. However, several people have written bindings for libCURL, which will do what you need. I've got one here: http://github.com/gmfawcett/d-play-libcurl/blob/master/fawcett/curl.d There's one on dsource, here: http://dsource.org/projects/curld/browser/trunk/curld Best, Graham
Aug 13 2010
next sibling parent Mengu <mengukagan gmail.com> writes:
Adam and Graham,

Thank you for the information. :)
Aug 13 2010
prev sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 08/13/2010 09:23 AM, Graham Fawcett wrote:
 Hi Mengu,

 On Fri, 13 Aug 2010 10:15:01 -0400, Mengu wrote:

 Mengu Wrote:

 Hello everyone,

 Python has a library named urllib which can be found at
 http://docs.python.org/library/urllib2.html.

 Does Phobos have anything similar to this library? All I need is
 fetching data from a web site.
Anyone has any idea on this matter?
I don't think there is anything usable in Phobos at the moment. However, several people have written bindings for libCURL, which will do what you need. I've got one here: http://github.com/gmfawcett/d-play-libcurl/blob/master/fawcett/curl.d There's one on dsource, here: http://dsource.org/projects/curld/browser/trunk/curld Best, Graham
Graham, I see your translation of libcurl's header is fairly complete. May I copy it into std.etc? We wanted to put libcurl there for a long time (Walter even exchanged emails with its author), and it would be a timesaver to copy yours. After we have the basic translation we should define higher-level APIs in Phobos that cloak it (libcurl has an unsafe interface). Thanks, Andrei
Aug 14 2010
parent reply Graham Fawcett <fawcett uwindsor.ca> writes:
Hi Andrei,

On Sat, 14 Aug 2010 09:35:21 -0500, Andrei Alexandrescu wrote:

 On 08/13/2010 09:23 AM, Graham Fawcett wrote:
 Hi Mengu,

 On Fri, 13 Aug 2010 10:15:01 -0400, Mengu wrote:

 Mengu Wrote:

 Hello everyone,

 Python has a library named urllib which can be found at
 http://docs.python.org/library/urllib2.html.

 Does Phobos have anything similar to this library? All I need is
 fetching data from a web site.
Anyone has any idea on this matter?
I don't think there is anything usable in Phobos at the moment. However, several people have written bindings for libCURL, which will do what you need. I've got one here: http://github.com/gmfawcett/d-play-libcurl/blob/master/fawcett/curl.d There's one on dsource, here: http://dsource.org/projects/curld/browser/trunk/curld Best, Graham
Graham, I see your translation of libcurl's header is fairly complete. May I copy it into std.etc? We wanted to put libcurl there for a long time (Walter even exchanged emails with its author), and it would be a timesaver to copy yours. After we have the basic translation we should define higher-level APIs in Phobos that cloak it (libcurl has an unsafe interface).
Yes -- I am happy to share it with the Phobos team. If you need me to sign a Contributor's Agreement or something, please email me. Regards, Graham
 
 
 Thanks,
 
 Andrei
Aug 14 2010
parent Jonathan M Davis <jmdavisprog gmail.com> writes:
On Saturday 14 August 2010 15:43:54 Graham Fawcett wrote:
 If you need me to sign a Contributor's Agreement or something, please
 email me.
Yes, sign right here, under "I agree to write quality code." ;) - Jonathan M Davis
Aug 14 2010