Results 1 to 3 of 3

Thread: Python requests - code takes minutes to run but work on other platforms than linux.

  1. #1
    Join Date
    Mar 2019
    Beans
    1

    Python requests - code takes minutes to run but work on other platforms than linux.

    Hello there,
    I have small issue with my (very) simple code.
    Code:
    import requests
    
    url = "https://api.coinmarketcap.com/v1/ticker/bitcoin"
    webObj = requests.get(url)
    webJson = webObj.json()
    print(webJson[0]["price_usd"])
    While running with python3 filenamy.py command this code takes minutes to start. Now I'm waiting 10 minutes for this script to run, same code on MacOS and Windows run without a problem. I guess the problem is with coinmarketcap page but I don't know - what kind of problem this is. If I put any other domain in url variable - everything is working fine.

  2. #2
    Join Date
    Jan 2017
    Beans
    235

    Re: Python requests - code takes minutes to run but work on other platforms than linu

    Does adding the following line help?
    Code:
    import json

  3. #3
    Join Date
    Mar 2017
    Beans
    1,018

    Re: Python requests - code takes minutes to run but work on other platforms than linu

    Runs fine here.
    Code:
    #!/usr/bin/env python3
    
    import requests
    
    url = "https://api.coinmarketcap.com/v1/ticker/bitcoin"
    webObj = requests.get(url)
    webJson = webObj.json()
    print(webJson[0]["price_usd"])
    Code:
    glen@Bionic:~$ /home/glen/scripts/aatest.py
    3907.41865656
    Try going to web api in your browser.
    https://api.coinmarketcap.com/v1/ticker/bitcoin/

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •