[Tutor] DEALING WITH API

Gaurav Lathwal glathwal at gmail.com
Fri Aug 7 22:55:53 CEST 2015


Thank you everyone for your help.

I managed to make a somewhat working model of what I had in my mind.
I will be sharing my code with you. Please tell me how to improve it. I
think it could be done in much less number of lines.
http://pastie.org/10336178

The first part which is handling the download is someone else's code I
found on StackOverflow. I am still unclear as to why it works.

On 7 August 2015 at 23:25, Alan Gauld <alan.gauld at btinternet.com> wrote:

> On 07/08/15 10:14, Gaurav Lathwal wrote:
>
> This time I am trying to fetch the required data using the API of the
>> website.
>>
>
> Which website? Don;t assume we can remember from your previous post
> or that we will want to go trawling the archives.
>
> The easier you make it for us to answer the more likely you are
> to get good answers.
>
> But, the problem I am having is I don't know how to make the request
>> properly.
>> When I enter the required URL in my browser, it downloads a .tgz which
>> includes all the updates that have taken place on the website in the last
>> 24 hours.
>>
>
> Can we see exactly what URLyou type in?
>
> So, when I use urlopen on the same url, & I try to read it, all I get is
>> gibberish.
>>
>
> Can you show us the actual code and the actual gibberish.
> Are you sure the gibberish is not just the tgz binary file
> contents? And if so why are you sure?
> ie. What did you do to test it?
>
> The more detailed facts we have the more we can help.
> code, error messages, python version, OS, -  all help.
>
> If I am unable to solve this problem, I am quitting programming, I have had
>> enough bad experiences. :\ :\
>>
>
> One thing I've learned about programming over the last 40 years
> is that you always have to go through a lot of trial and error to
> get new stuff working. Think of it as experimenting and having
> fun discovering new things and it becomes less painful.
> Think of it as just inconvenient errors and its just
> frustrating... It's all about the state of mind :-)
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list