Python Forum
Problems with using request in python 3
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problems with using request in python 3
#2
I added python tags please use them in all future posts. (see BBCODE)
use requests, you will have to install the package, if you are unfamiliar with the install process, open a command window and type:
pip install requests
code:
import requests


def download_stock_data(url, savefile):
    page =  requests.get(url, allow_redirects=False)
    if page.status_code == 200:
        with open(savefile, 'wb') as f:
            f.write(page.content)
    else:
        print('Error downloading file')
        # ... more processing here ...

def main():
    download_stock_data(url='http://www.google.com/finance/historical?q=NASDAQ:GOOG&output=csv',
                        savefile='goog.csv')

if __name__ == '__main__':
    main()
But .... Google responds with:
Quote:Google
Sorry...
We're sorry...

... but your computer or network may be sending automated queries. To protect our users, we can't process your request right now.
See Google Help for more information.
Reply


Messages In This Thread
RE: Problems with using request in python 3 - by Larz60+ - Feb-15-2018, 04:56 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Debian 11 Bullseye | Python 3.9.x | pip install mysql-connector-python-rf problems BrandonKastning 4 6,772 Feb-05-2022, 08:25 PM
Last Post: BrandonKastning
  how can I correct the Bad Request error on my curl request tomtom 8 5,133 Oct-03-2021, 06:32 AM
Last Post: tomtom
  Python Request Errors PythonNoob1998 7 4,071 Jan-07-2021, 05:18 PM
Last Post: buran
  ImportError: cannot import name 'Request' from 'request' abhishek81py 1 3,972 Jun-18-2020, 08:07 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020