I need to write some code that can request to download from a company site. I need to download the file as csv (which is a possibility directly from the site, in other words.. from the site you can navigate to the file that you want to download.. and click 'download as csv').. When I run the request method I get status code 200 (which is good news).. when I take that what was downloaded and tell Pandas to put in a dataframe I get a dataframe looking like this html code
<!DOCTYPE html>
0 <html lang="en">
1 <head>
2 <meta charset="UTF-8">
3 <link rel="stylesheet" href="/static/shift_sta...
4 <title>Login</title>
5 </head>
6 <body>
7 <div id="main-container">
8 <div id="main">
9 <h1>
10 </h1>
11 <div id="login-form">
12 <form action="/auth/login/" method="post" id="...
13 <fieldset>
14 <label for="username">Username</label>
15 <input autocapitalize="off" autocorrect="off" ...
16 </fieldset>
17 <fieldset>
18 <label for="password">Password</label>
19 <input class="text-input" id="password" name="...
20 </fieldset>
21 <fieldset>
22 <span class="errormessage"></span>
23 </fieldset>
24 <div id="form_btn">
25 <input id="signin-btn" class="btn btn-blue" ty...
26 <!-- <a href="/sb/"><input id="inscription-btn...
27 </div>
28 </form>
29 </div>
30 </div>
31 </div>
32 <script>
33 localStorage.clear();
34 </script>
35 </body>
36 </html>
The code which was run (for security purposes a bit altered):
r = requests.get('https://python-dashboard.xxourcompanyxx.com/minesite/xxthecompanywhosdatawewantxx/results-explorer/download-dat-as-tsv/xxchannelxx/by-shift/201911240/execution/1574738314808/equipment/by-class/haultruck/xxequipmentxx/Base.dat.xz&AsCSV=true',
auth=('myname.surname@my.company', 'MyP@ssw0rd'))
print(f"Response code from server: {r.status_code}")
if r.status_code == 200:
print('Status 200')
decoded_content = r.content.decode('utf-8')
df_h = pd.read_csv(io.StringIO(decoded_content))
Which isn't correct, I know how the data looks..and this isn't it.. Please help me to get this html code in readable csv/pandas dataframe..