-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdece.py
More file actions
42 lines (33 loc) · 1.24 KB
/
dece.py
File metadata and controls
42 lines (33 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import requests
from bs4 import BeautifulSoup
doc_id = "2PACX-1vQGUck9HIFCyezsrBSnmENk5ieJuYwpt7YHYEzeNJkIb9OSDdx-ov2nRNReKQyey-cwJOoEKUhLmN9z"
urlu = f"https://docs.google.com/document/u/0/d/e/{doc_id}/pub?pli=1"
def decode_print(url):
response = requests.get(url)
if response.status_code == 200:
soup = BeautifulSoup(response.text, 'html.parser')
tables = soup.find_all('table')
table = tables[0]
rows = table.find_all('tr')[1:]
xs = []
ys = []
for row in rows:
cells = row.find_all ('td')
x_co = cells[0].get_text(strip=True)
y_co = cells[2].get_text(strip=True)
xs.append(int(x_co))
ys.append(int(y_co))
max_x = max(xs)
max_y = max(ys)
myframe = [[' ' for _ in range(max_x + 1)] for _ in range(max_y + 1)]
for row in rows:
cells = row.find_all ('td')
x_co = cells[0].get_text(strip=True)
y_co = cells[2].get_text(strip=True)
myframe[int(y_co)][int(x_co)] = cells[1].get_text(strip=True)
rev_mf = myframe[::-1]
for row in rev_mf:
print(''.join(row))
else:
print("Error", response.status_code)
decode_print(urlu)