Home > Net >  Saving Data with Requests Library
Saving Data with Requests Library

Time:10-07

Good night, i'm trying to download a excel table from a URL with Requests library, but when I try to save the data in tabular mode, i obtain all the info from the URL but in HTML/text code, and i don't know how to obtain the table with the relevant information:

URL = 'https://docs.google.com/spreadsheets/d/1PS2_yAvNVEuSY0gI8Nky73TQMcx_G1i18lm--jOGfAA/edit#gid=514147473'
response = requests.get(URL)

with open('out.csv', 'w', newline='') as f:
    writer = csv.writer(f)
    for line in response.iter_lines():
      writer.writerow(csvheader)
      writer.writerow(line.decode('utf-8').split(','))

and obtain some like:

<!DOCTYPE html><html lang="en-US"><head><script nonce="JUuaJUl__6QGcoAgULSNpA">var DOCS_timing={}; DOCS_timing[\'pls\']=new Date().getTime();</script><meta property="og:title" content="Datos Argentina - Museos"><meta property="og:type" content="article"><meta property="og:site_name" content="Google Docs"><meta property="og:url" content="https://docs.google.com/spreadsheets/d/1PS2_yAvNVEuSY0gI8Nky73TQMcx_G1i18lm--jOGfAA/edit?usp=embed_facebook"><meta property="og:image" content="https://lh3.googleusercontent.com/N5mR8roa7WP4kn9xvBlt5U-OOKKkSkIGTofqsHXrk2iio25IlUBc-3V9qNJ8sg9Jqptk-mV4H1y7FQ=w1200-h630-p"><meta property="og:image:width" 

the info is some like: enter image description here

  • Related